# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
981392 | 2024-05-13T06:51:28 Z | Amaarsaa | Strange Device (APIO19_strange_device) | C++14 | 351 ms | 30976 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 | 0 ms | 348 KB | Output is correct |
2 | Correct | 3 ms | 1096 KB | Output is correct |
3 | Correct | 4 ms | 1100 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 | 0 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 0 ms | 344 KB | Output is correct |
10 | Correct | 1 ms | 348 KB | Output is correct |
11 | Correct | 0 ms | 348 KB | Output is correct |
12 | Correct | 0 ms | 348 KB | Output is correct |
13 | Correct | 0 ms | 348 KB | Output is correct |
14 | Correct | 1 ms | 348 KB | Output is correct |
15 | Correct | 0 ms | 348 KB | Output is correct |
16 | Correct | 4 ms | 1112 KB | Output is correct |
17 | Correct | 33 ms | 4476 KB | Output is correct |
18 | Correct | 0 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 1 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 | 1 ms | 348 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 | 464 KB | Output is correct |
5 | Correct | 209 ms | 30976 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 313 ms | 18516 KB | Output is correct |
3 | Incorrect | 219 ms | 344 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 | 313 ms | 18516 KB | Output is correct |
3 | Incorrect | 219 ms | 344 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 | 313 ms | 18516 KB | Output is correct |
3 | Incorrect | 219 ms | 344 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 | 31 ms | 2572 KB | Output is correct |
3 | Correct | 34 ms | 2516 KB | Output is correct |
4 | Correct | 351 ms | 18772 KB | Output is correct |
5 | Correct | 30 ms | 2516 KB | Output is correct |
6 | Correct | 31 ms | 2520 KB | Output is correct |
7 | Correct | 31 ms | 2520 KB | Output is correct |
8 | Correct | 32 ms | 2520 KB | Output is correct |
9 | Correct | 30 ms | 2520 KB | Output is correct |
10 | Correct | 31 ms | 2552 KB | Output is correct |
11 | Correct | 31 ms | 2520 KB | Output is correct |
12 | Correct | 27 ms | 2620 KB | Output is correct |
13 | Correct | 32 ms | 2520 KB | Output is correct |
14 | Correct | 313 ms | 19076 KB | Output is correct |
15 | Correct | 32 ms | 2508 KB | Output is correct |
16 | Correct | 305 ms | 17316 KB | Output is correct |
17 | Correct | 296 ms | 18424 KB | Output is correct |
18 | Correct | 0 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 3 ms | 1096 KB | Output is correct |
3 | Correct | 4 ms | 1100 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 | 0 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 0 ms | 344 KB | Output is correct |
10 | Correct | 1 ms | 348 KB | Output is correct |
11 | Correct | 0 ms | 348 KB | Output is correct |
12 | Correct | 0 ms | 348 KB | Output is correct |
13 | Correct | 0 ms | 348 KB | Output is correct |
14 | Correct | 1 ms | 348 KB | Output is correct |
15 | Correct | 0 ms | 348 KB | Output is correct |
16 | Correct | 4 ms | 1112 KB | Output is correct |
17 | Correct | 33 ms | 4476 KB | Output is correct |
18 | Correct | 0 ms | 348 KB | Output is correct |
19 | Correct | 0 ms | 348 KB | Output is correct |
20 | Correct | 0 ms | 348 KB | Output is correct |
21 | Correct | 1 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 | 1 ms | 348 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 | 464 KB | Output is correct |
28 | Correct | 209 ms | 30976 KB | Output is correct |
29 | Correct | 0 ms | 348 KB | Output is correct |
30 | Correct | 313 ms | 18516 KB | Output is correct |
31 | Incorrect | 219 ms | 344 KB | Output isn't correct |
32 | Halted | 0 ms | 0 KB | - |