답안 #240335

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
240335 2020-06-19T12:58:26 Z valerikk 이상한 기계 (APIO19_strange_device) C++14
0 / 100
5000 ms 86332 KB
#include<bits/stdc++.h>
using namespace std;

#define x first
#define y second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define f(i, n) for (int i = 0; i < (n); i++)

#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()

#define ll long long
#define ld long double
#define int long long
#define pii pair<int, int>

int get_ob(vector<pii> a) {
    vector<pii> v;
    f(i, sz(a)) {
        v.eb(a[i].x, 0);
        v.eb(a[i].y + 1, 1);
    }
    sort(all(v));
    int ob = 0, cnt = 0;
    f(i, sz(v) - 1) {
        if (v[i].x == 0) cnt++; else cnt--;
        if (cnt) ob += v[i + 1].x - v[i].x;
    }
    return ob;
}

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, a, b;
    cin >> n >> a >> b;
    int p = a / __gcd(a, b + 1);
    vector<int> l(n), r(n);
    f(i, n) cin >> l[i] >> r[i];
    int ans = 0;
    f(z, b) {
        vector<pii> v;
        f(i, n) {
            if (z > r[i]) continue;
            int ql = (l[i] - z + b - 1) / b;
            int qr = (r[i] - z) / b;
            if (ql <= qr) {
                ql %= p;
                qr %= p;
                if (ql <= qr) {
                    v.pb({ql, qr});
                } else {
                    v.pb({0, qr});
                    v.pb({ql, p - 1});
                }
            }
        }
        ans += get_ob(v);
    }
    cout << ans;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Incorrect 903 ms 920 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Execution timed out 5082 ms 384 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Incorrect 16 ms 512 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Incorrect 728 ms 86332 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Incorrect 728 ms 86332 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Incorrect 728 ms 86332 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Execution timed out 5074 ms 5624 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Incorrect 903 ms 920 KB Output isn't correct
3 Halted 0 ms 0 KB -