# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
196916 | 2020-01-17T16:16:27 Z | tincamatei | Strange Device (APIO19_strange_device) | C++14 | 5000 ms | 2424 KB |
#include <bits/stdc++.h> using namespace std; const long long INF = 1LL << 62; long long gcd(long long a, long long b) { long long r; while(b > 0) { r = a % b; a = b; b = r; } return a; } set<pair<long long, long long> > ranges; bool badSet[1000000]; long long insertRange(long long a, long long b) { /*set<pair<long long, long long> >::iterator it; it = ranges.lower_bound(make_pair(a, -INF)); if(it != ranges.begin()) { set<pair<long long, long long> >::iterator it2; it2 = it; it2--; if(it2->second >= a) { it--; a = it->first; } } long long rez = 0LL; vector<pair<long long, long long> > toErase; while(it != ranges.end() && it->first <= b) { toErase.push_back(*it); rez = rez - (it->second - it->first + 1); b = it->second; it++; } for(auto it: toErase) ranges.erase(it); ranges.insert(make_pair(a, b)); rez = rez + b - a + 1; */ long long rez = 0LL; for(int i = a; i <= b; ++i) if(!badSet[i]) { badSet[i] = true; ++rez; } return rez; } int main() { int n; long long A, B, loopSize, xSkip, convolutions; scanf("%d%lld%lld", &n, &A, &B); xSkip = B % A + 1; convolutions = A / gcd(A, xSkip); if(convolutions <= INF / B) loopSize = B * convolutions; else loopSize = INF; long long rez = 0LL; for(int i = 0; i < n; ++i) { long long l, r; scanf("%lld%lld", &l, &r); if(r - l + 1 >= loopSize) rez = rez + insertRange(0, loopSize - 1); else { l = l % loopSize; r = r % loopSize; if(r >= l) rez = rez + insertRange(l, r); else { rez = rez + insertRange(0, r) + insertRange(l, loopSize - 1); } } } printf("%lld\n", rez); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Runtime error | 3 ms | 504 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Runtime error | 3 ms | 2424 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 256 KB | Output is correct |
2 | Correct | 4 ms | 1144 KB | Output is correct |
3 | Correct | 4 ms | 1316 KB | Output is correct |
4 | Correct | 4 ms | 1144 KB | Output is correct |
5 | Execution timed out | 5023 ms | 1576 KB | Time limit exceeded |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Runtime error | 3 ms | 504 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Runtime error | 3 ms | 504 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Runtime error | 3 ms | 504 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Runtime error | 3 ms | 496 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Runtime error | 3 ms | 504 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
3 | Halted | 0 ms | 0 KB | - |