# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
444237 | 2021-07-13T12:16:15 Z | qwerasdfzxcl | Strange Device (APIO19_strange_device) | C++14 | 586 ms | 25252 KB |
#include <bits/stdc++.h> typedef __int128_t l128; typedef long long ll; using namespace std; int main(){ int n; ll x, y; scanf("%d %lld %lld", &n, &x, &y); l128 t = y; t *= x/__gcd(x, y+1); ll MOD = (ll)1e18+10; if (t<=(ll)1e18+10) MOD = t; //printf("%lld\n", MOD); vector<pair<ll, ll>> ran; for (int i=0;i<n;i++){ ll tmp1, tmp2; scanf("%lld %lld", &tmp1, &tmp2); if (tmp2-tmp1+1>=MOD) {printf("%lld\n", MOD); return 0;} tmp2++; tmp1 %= MOD, tmp2 %= MOD; if (tmp2<tmp1){ ran.emplace_back(tmp1, MOD); ran.emplace_back(0, tmp2); } else ran.emplace_back(tmp1, tmp2); } sort(ran.begin(), ran.end()); ll ans = 0; pair<ll, ll> cur = {0, 0}; n = ran.size(); for (int i=0;i<n;i++){ if (cur.first<=ran[i].first && ran[i].first<=cur.second){ ans += ran[i].second-cur.second; cur.second = ran[i].second; } else{ ans += ran[i].second-ran[i].first; cur = ran[i]; } } printf("%lld\n", ans); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Incorrect | 7 ms | 972 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 288 KB | Output is correct |
3 | Correct | 0 ms | 204 KB | Output is correct |
4 | Correct | 1 ms | 204 KB | Output is correct |
5 | Correct | 0 ms | 204 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Incorrect | 1 ms | 304 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 509 ms | 17136 KB | Output is correct |
3 | Correct | 487 ms | 17128 KB | Output is correct |
4 | Correct | 499 ms | 24544 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 509 ms | 17136 KB | Output is correct |
3 | Correct | 487 ms | 17128 KB | Output is correct |
4 | Correct | 499 ms | 24544 KB | Output is correct |
5 | Correct | 1 ms | 204 KB | Output is correct |
6 | Correct | 501 ms | 25200 KB | Output is correct |
7 | Correct | 573 ms | 25232 KB | Output is correct |
8 | Correct | 506 ms | 25204 KB | Output is correct |
9 | Correct | 561 ms | 25252 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 509 ms | 17136 KB | Output is correct |
3 | Correct | 487 ms | 17128 KB | Output is correct |
4 | Correct | 499 ms | 24544 KB | Output is correct |
5 | Correct | 1 ms | 204 KB | Output is correct |
6 | Correct | 51 ms | 5680 KB | Output is correct |
7 | Correct | 55 ms | 5684 KB | Output is correct |
8 | Correct | 51 ms | 5700 KB | Output is correct |
9 | Correct | 54 ms | 5684 KB | Output is correct |
10 | Correct | 59 ms | 5580 KB | Output is correct |
11 | Correct | 52 ms | 5600 KB | Output is correct |
12 | Correct | 52 ms | 5608 KB | Output is correct |
13 | Correct | 58 ms | 5684 KB | Output is correct |
14 | Correct | 49 ms | 5652 KB | Output is correct |
15 | Incorrect | 56 ms | 5724 KB | Output isn't correct |
16 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 55 ms | 5740 KB | Output is correct |
3 | Correct | 56 ms | 5648 KB | Output is correct |
4 | Correct | 567 ms | 17144 KB | Output is correct |
5 | Correct | 53 ms | 5680 KB | Output is correct |
6 | Correct | 52 ms | 5648 KB | Output is correct |
7 | Correct | 64 ms | 5684 KB | Output is correct |
8 | Correct | 54 ms | 5636 KB | Output is correct |
9 | Correct | 54 ms | 5684 KB | Output is correct |
10 | Correct | 62 ms | 5592 KB | Output is correct |
11 | Correct | 55 ms | 5736 KB | Output is correct |
12 | Correct | 48 ms | 5584 KB | Output is correct |
13 | Correct | 53 ms | 5680 KB | Output is correct |
14 | Incorrect | 586 ms | 17140 KB | Output isn't correct |
15 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Incorrect | 7 ms | 972 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |