# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
795495 | 2023-07-27T10:29:12 Z | RecursiveCo | Strange Device (APIO19_strange_device) | C++14 | 580 ms | 33372 KB |
// CF template, version 3.0 #include <bits/stdc++.h> using namespace std; #define improvePerformance ios_base::sync_with_stdio(false); cin.tie(0) #define getTest int t; cin >> t #define eachTest for (int _var=0;_var<t;_var++) #define get(name) int (name); cin >> (name) #define out(o) cout << (o) #define getList(cnt, name) vector<int> (name); for (int _=0;_<(cnt);_++) { get(a); (name).push_back(a); } #define sortl(name) sort((name).begin(), (name).end()) #define rev(name) reverse((name).begin(), (name).end()) #define forto(name, var) for (int (var) = 0; (var) < (name); (var)++) #define decision(b) if (b){out("YES");}else{out("NO");} #define int long long int signed main() { improvePerformance; //getTest; //eachTest { get(n); get(A); get(B); bool toobig = 2e18 / A <= B; // should be good enough, theoretically. vector<pair<int, int>> events; forto(n, i) { get(l); get(r); if (!toobig) { if (r - l + 1 >= A * B) { out(A * B); return 0; } l %= A * B; r %= A * B; } events.push_back({l, -1}); events.push_back({r, 1}); if (r < l) { events.push_back({0, -1}); events.push_back({A * B - 1, 1}); } } int ans = 0; int last = -1; int m = events.size(); sortl(events); int balance = 0; forto(m, i) { balance -= events[i].second; if (last == -1 && balance > 0) { last = events[i].first; } else if (balance == 0) { ans += events[i].first - last + 1; last = -1; } } out(ans); //} }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 4 ms | 984 KB | Output is correct |
3 | Correct | 5 ms | 984 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 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Correct | 255 ms | 33236 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 413 ms | 33372 KB | Output is correct |
3 | Incorrect | 353 ms | 33248 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 | 413 ms | 33372 KB | Output is correct |
3 | Incorrect | 353 ms | 33248 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 | 413 ms | 33372 KB | Output is correct |
3 | Incorrect | 353 ms | 33248 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 | 42 ms | 4460 KB | Output is correct |
3 | Correct | 44 ms | 4516 KB | Output is correct |
4 | Correct | 580 ms | 33196 KB | Output is correct |
5 | Correct | 41 ms | 4556 KB | Output is correct |
6 | Correct | 41 ms | 4572 KB | Output is correct |
7 | Correct | 42 ms | 4488 KB | Output is correct |
8 | Correct | 55 ms | 4468 KB | Output is correct |
9 | Correct | 40 ms | 4540 KB | Output is correct |
10 | Correct | 45 ms | 4516 KB | Output is correct |
11 | Correct | 57 ms | 4548 KB | Output is correct |
12 | Correct | 51 ms | 4556 KB | Output is correct |
13 | Correct | 52 ms | 4504 KB | Output is correct |
14 | Correct | 482 ms | 33276 KB | Output is correct |
15 | Incorrect | 59 ms | 4548 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 | 4 ms | 984 KB | Output is correct |
3 | Correct | 5 ms | 984 KB | Output is correct |
4 | Incorrect | 0 ms | 212 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |