Submission #554216

# Submission time Handle Problem Language Result Execution time Memory
554216 2022-04-28T03:08:15 Z happypotato Strange Device (APIO19_strange_device) C++17
5 / 100
1462 ms 33360 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
void solve() {
    int n, a, b;
    cin >> n >> a >> b;
    priority_queue<pair<int, bool>, vector<pair<int, bool> >, greater<pair<int, bool> > > pq;
    int mod;
    if (log2(a) + log2(b) > log2(4e18)) mod = 4e18;
    else mod = a * b;
    while (n--) {
        int l, r;
        cin >> l >> r;
        l %= mod; r %= mod;
        if (l > r) {
            pq.push({l, true});
            pq.push({mod, false});
            pq.push({0, true});
            pq.push({r + 1, false});
        } else {
            pq.push({l, true});
            pq.push({r + 1, false});
        }
    }
    int prev = 0, ans = 0;
    int cnt = 0;
    while (!pq.empty()) {
        pair<int, bool> cur = pq.top();
        pq.pop();
        if (cnt) ans += cur.first - prev;
        prev = cur.first;
        cnt += (cur.second ? 1 : -1);
    }
    cout << ans << endl;
}
signed main() {
    solve();
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 14 ms 840 KB Output is correct
3 Correct 16 ms 832 KB Output is correct
4 Incorrect 0 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 2 ms 340 KB Output is correct
3 Correct 2 ms 340 KB Output is correct
4 Correct 2 ms 340 KB Output is correct
5 Correct 1029 ms 33360 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1450 ms 33268 KB Output is correct
3 Incorrect 1462 ms 33288 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1450 ms 33268 KB Output is correct
3 Incorrect 1462 ms 33288 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1450 ms 33268 KB Output is correct
3 Incorrect 1462 ms 33288 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 143 ms 4464 KB Output is correct
3 Correct 138 ms 4492 KB Output is correct
4 Correct 1412 ms 33348 KB Output is correct
5 Correct 141 ms 4524 KB Output is correct
6 Correct 148 ms 4444 KB Output is correct
7 Correct 139 ms 4408 KB Output is correct
8 Correct 141 ms 4420 KB Output is correct
9 Correct 138 ms 4504 KB Output is correct
10 Correct 147 ms 4480 KB Output is correct
11 Correct 140 ms 4496 KB Output is correct
12 Correct 140 ms 4404 KB Output is correct
13 Correct 140 ms 4420 KB Output is correct
14 Correct 1413 ms 33216 KB Output is correct
15 Incorrect 141 ms 4408 KB Output isn't correct
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 14 ms 840 KB Output is correct
3 Correct 16 ms 832 KB Output is correct
4 Incorrect 0 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -