# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
981397 | 2024-05-13T06:56:09 Z | Amaarsaa | Strange Device (APIO19_strange_device) | C++14 | 361 ms | 18936 KB |
#include<bits/stdc++.h> using namespace std; using ll = long long ; int main() { // freopen("moocast.in", "r", stdin); // freopen("moocast.out", "w", stdout); ios::sync_with_stdio(false); cin.tie(NULL); ll t, n, m, ans,l, a, b, s, lo, hi, mid, sum, x, y, r, p, i, j; cin >> n >> a >> b; s = __gcd(b + 1, a); s = a / s; p = 1e18/s; if ( p < s) { s= 0; for (i = 1; i <= n; i ++) { cin >> x >> y; s += (y -x + 1); } cout << s<< endl; return 0; } s = s * b; ans = 0; map < ll, ll > A; vector < pair <ll,ll > > v; for (i = 1; i <= n; i ++) { cin >> x >> y; if ( x / s == y / s) { v.push_back({x%s, y%s}); } else { if ( x / s + 1 == y / s) { v.push_back({x%s, s - 1}); v.push_back({0, y%s}); } else { cout << s << endl; return 0; } } } sort(v.begin(), v.end()); ll mx = -1; for (i = 0; i < v.size(); i ++) { if ( v[i].first <= mx) { ans += max(0ll, v[i].second - mx); } else ans += (v[i].second - v[i].first + 1); mx =max(mx, v[i].second); } cout << ans << endl; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 3 ms | 688 KB | Output is correct |
3 | Correct | 4 ms | 736 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 1 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 1 ms | 348 KB | Output is correct |
10 | Correct | 1 ms | 348 KB | Output is correct |
11 | Correct | 0 ms | 348 KB | Output is correct |
12 | Correct | 1 ms | 344 KB | Output is correct |
13 | Correct | 0 ms | 348 KB | Output is correct |
14 | Correct | 0 ms | 348 KB | Output is correct |
15 | Correct | 1 ms | 348 KB | Output is correct |
16 | Correct | 4 ms | 736 KB | Output is correct |
17 | Correct | 35 ms | 2520 KB | Output is correct |
18 | Correct | 1 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 1 ms | 348 KB | Output is correct |
4 | Correct | 1 ms | 356 KB | Output is correct |
5 | Correct | 221 ms | 18696 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 298 ms | 18876 KB | Output is correct |
3 | Incorrect | 219 ms | 428 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 298 ms | 18876 KB | Output is correct |
3 | Incorrect | 219 ms | 428 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 298 ms | 18876 KB | Output is correct |
3 | Incorrect | 219 ms | 428 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 34 ms | 2544 KB | Output is correct |
3 | Correct | 32 ms | 2520 KB | Output is correct |
4 | Correct | 361 ms | 18788 KB | Output is correct |
5 | Correct | 31 ms | 2468 KB | Output is correct |
6 | Correct | 31 ms | 2520 KB | Output is correct |
7 | Correct | 38 ms | 2520 KB | Output is correct |
8 | Correct | 36 ms | 2516 KB | Output is correct |
9 | Correct | 31 ms | 2516 KB | Output is correct |
10 | Correct | 32 ms | 2516 KB | Output is correct |
11 | Correct | 31 ms | 2772 KB | Output is correct |
12 | Correct | 28 ms | 2516 KB | Output is correct |
13 | Correct | 31 ms | 2484 KB | Output is correct |
14 | Correct | 316 ms | 18936 KB | Output is correct |
15 | Correct | 31 ms | 2520 KB | Output is correct |
16 | Correct | 282 ms | 17336 KB | Output is correct |
17 | Correct | 291 ms | 17848 KB | Output is correct |
18 | Correct | 0 ms | 344 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 3 ms | 688 KB | Output is correct |
3 | Correct | 4 ms | 736 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 1 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 1 ms | 348 KB | Output is correct |
10 | Correct | 1 ms | 348 KB | Output is correct |
11 | Correct | 0 ms | 348 KB | Output is correct |
12 | Correct | 1 ms | 344 KB | Output is correct |
13 | Correct | 0 ms | 348 KB | Output is correct |
14 | Correct | 0 ms | 348 KB | Output is correct |
15 | Correct | 1 ms | 348 KB | Output is correct |
16 | Correct | 4 ms | 736 KB | Output is correct |
17 | Correct | 35 ms | 2520 KB | Output is correct |
18 | Correct | 1 ms | 348 KB | Output is correct |
19 | Correct | 1 ms | 348 KB | Output is correct |
20 | Correct | 0 ms | 348 KB | Output is correct |
21 | Correct | 0 ms | 348 KB | Output is correct |
22 | Correct | 0 ms | 348 KB | Output is correct |
23 | Correct | 0 ms | 348 KB | Output is correct |
24 | Correct | 0 ms | 344 KB | Output is correct |
25 | Correct | 1 ms | 348 KB | Output is correct |
26 | Correct | 1 ms | 348 KB | Output is correct |
27 | Correct | 1 ms | 356 KB | Output is correct |
28 | Correct | 221 ms | 18696 KB | Output is correct |
29 | Correct | 0 ms | 344 KB | Output is correct |
30 | Correct | 298 ms | 18876 KB | Output is correct |
31 | Incorrect | 219 ms | 428 KB | Output isn't correct |
32 | Halted | 0 ms | 0 KB | - |