AtCoder Beginner Contest 030

Submission #7563096

Source codeソースコード

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define INF (ll)2e9
#define MOD ((ll)1e9+7)
#define ALL(v) v.begin(), v.end()
#define SZ(x) ((int)(x).size())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define bit(n) (1LL<<(n))
#define cauto const auto&
#define println(v) cout << v << "\n";

inline vector<vector<vector<ll>>> makeVector(ll i, ll j, ll k) {
    vector<vector<vector<ll>>> v(i, vector<vector<ll>>(j, vector<ll>(k, 0)));
    return v;
}
inline vector<vector<ll>> makeVector(ll i, ll j) {
    vector<vector<ll>> v(i, vector<ll>(j, 0));
    return v;
}

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template <class InputIterator>
InputIterator adv(InputIterator x, typename std::iterator_traits<InputIterator>::difference_type n) {
    advance(x, n);
    return x;
}

class mod {
    static ll fact[];
public:

    template<class... A>
    static ll mul(A... args) {
        ll res = 1;
        for (ll i : std::initializer_list<ll>{args...}) {
            res = (res * i) % MOD;
        }
        return res;
    }

    static ll power(ll base, ll exp) {
        if (exp == 0) return 1;
        if (exp & 1) {
            return mul(base, power(base, exp - 1));
        } else {
            ll p = power(base, exp / 2);
            return mul(p, p);
        }
    }

    static ll factorial(int n) {
        if (fact[n] != 0) return fact[n];
        if (n == 0) return 1;
        return fact[n] = mul(n, factorial(n - 1));
    }

    static ll inverse(int n) {
        return power(n, MOD - 2);
    }

    static ll comb(int n, int r) {
        if (r < 0 || r > n) return 0;
        return mul(factorial(n), inverse(factorial(n - r)), inverse(factorial(r)));
    }

    template<class... A>
    static ll div(ll dividend, A... args) {
        ll res = dividend;
        for (ll i : std::initializer_list<ll>{args...}) {
            res = mul(res, inverse(i));
        }
        return res;
    }

    template<class... A>
    static ll add(A... args) {
        ll res = 0;
        for (ll i : std::initializer_list<ll>{args...}) {
            res = (res + i) % MOD;
        }
        return res;
    }

    template<class... A>
    static ll sub(ll l, A... args) {
        ll res = l;
        for (ll i : std::initializer_list<ll>{args...}) {
            res = (res - i + MOD) % MOD;
        }
        return res;
    }
};
ll mod::fact[(int) 1e6 + 1];

int ni() {
    int i;
    cin >> i;
    return i;
}
ll nll() {
    ll l;
    cin >> l;
    return l;
}

int main()
{
    int N = ni(), M = ni(), X = ni(), Y = ni();
    vector<int> a;
    vector<int> b;

    REP(i, N) a.push_back(ni());
    REP(i, M) b.push_back(ni());

    int ai=0, bi=0;
    int isA = true;
    int now = 0;
    int ans = 0;
    while(true) {
        if (isA) {
            while(ai < N && a[ai] < now) ai++;
            if (ai == N) {
                break;
            }
            now = a[ai] + X;
            ai++;
            isA = false;
        } else {
            while(bi < M && b[bi] < now) bi++;
            if (bi == M) {
                break;
            }
            now = b[bi] + Y;
            bi++;
            isA = true;
            ans++;
        }
    }

    println(ans);

    return 0;
}

Submission

Task問題 C - 飛行機乗り
User nameユーザ名 yutake
Created time投稿日時
Language言語 C++14 (GCC 5.4.1)
Status状態 AC
Score得点 100
Source lengthソースコード長 3854 Byte
File nameファイル名
Exec time実行時間 74 ms
Memory usageメモリ使用量 1400 KB

Test case

Set

Set name Score得点 / Max score Cases
Sample - subtask0_sample_01.txt,subtask0_sample_02.txt,subtask0_sample_03.txt
Subtask1 30 / 30 subtask0_0.txt,subtask0_1.txt,subtask0_10.txt,subtask0_11.txt,subtask0_12.txt,subtask0_13.txt,subtask0_14.txt,subtask0_2.txt,subtask0_3.txt,subtask0_4.txt,subtask0_5.txt,subtask0_6.txt,subtask0_7.txt,subtask0_8.txt,subtask0_9.txt,subtask0_sample_01.txt,subtask0_sample_02.txt,subtask0_sample_03.txt
All 70 / 70 subtask0_0.txt,subtask0_1.txt,subtask0_10.txt,subtask0_11.txt,subtask0_12.txt,subtask0_13.txt,subtask0_14.txt,subtask0_2.txt,subtask0_3.txt,subtask0_4.txt,subtask0_5.txt,subtask0_6.txt,subtask0_7.txt,subtask0_8.txt,subtask0_9.txt,subtask0_sample_01.txt,subtask0_sample_02.txt,subtask0_sample_03.txt,subtask1_0.txt,subtask1_1.txt,subtask1_10.txt,subtask1_11.txt,subtask1_12.txt,subtask1_13.txt,subtask1_14.txt,subtask1_2.txt,subtask1_3.txt,subtask1_4.txt,subtask1_5.txt,subtask1_6.txt,subtask1_7.txt,subtask1_8.txt,subtask1_9.txt

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
subtask0_0.txt AC 54 ms 1400 KB
subtask0_1.txt AC 33 ms 892 KB
subtask0_10.txt AC 39 ms 1016 KB
subtask0_11.txt AC 43 ms 1148 KB
subtask0_12.txt AC 47 ms 1400 KB
subtask0_13.txt AC 37 ms 1016 KB
subtask0_14.txt AC 47 ms 1272 KB
subtask0_2.txt AC 42 ms 1016 KB
subtask0_3.txt AC 43 ms 1016 KB
subtask0_4.txt AC 41 ms 1148 KB
subtask0_5.txt AC 31 ms 892 KB
subtask0_6.txt AC 53 ms 1400 KB
subtask0_7.txt AC 44 ms 1144 KB
subtask0_8.txt AC 32 ms 892 KB
subtask0_9.txt AC 55 ms 1400 KB
subtask0_sample_01.txt AC 1 ms 256 KB
subtask0_sample_02.txt AC 1 ms 256 KB
subtask0_sample_03.txt AC 1 ms 256 KB
subtask1_0.txt AC 72 ms 1400 KB
subtask1_1.txt AC 66 ms 1272 KB
subtask1_10.txt AC 45 ms 892 KB
subtask1_11.txt AC 64 ms 1272 KB
subtask1_12.txt AC 70 ms 1272 KB
subtask1_13.txt AC 74 ms 1272 KB
subtask1_14.txt AC 56 ms 1148 KB
subtask1_2.txt AC 68 ms 1272 KB
subtask1_3.txt AC 58 ms 1272 KB
subtask1_4.txt AC 65 ms 1400 KB
subtask1_5.txt AC 65 ms 1400 KB
subtask1_6.txt AC 63 ms 1272 KB
subtask1_7.txt AC 62 ms 1144 KB
subtask1_8.txt AC 64 ms 1272 KB
subtask1_9.txt AC 71 ms 1400 KB