# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
145581 | 2019-08-20T12:26:58 Z | mhy908 | Strange Device (APIO19_strange_device) | C++14 | 739 ms | 18896 KB |
#include <bits/stdc++.h> using namespace std; typedef unsigned long long LL; typedef pair<int, int> pii; typedef pair<LL, LL> pll; int n; LL a, b; bool iscalc=true; LL gcd(LL x, LL y) { if(!y)return x; return gcd(y, x%y); } vector<pll> vc; int main() { scanf("%d %lld %lld", &n, &a, &b); LL temp=a/gcd(a, b+1); LL pv=0; LL ans=0; if(log10(temp)+log10(b)>=18.1)iscalc=false; else temp*=b; for(int i=1; i<=n; i++){ LL x, y; scanf("%lld %lld", &x, &y); if(!iscalc){ vc.push_back({x, y}); continue; } LL xx=x%temp; LL yy=y%temp; if(x==y)vc.push_back({xx, xx}); else{ if(x/temp==y/temp)vc.push_back({xx, yy}); else if(x/temp+1==y/temp&&xx>=yy)vc.push_back({xx, temp-1}), vc.push_back({0, yy}); else vc.push_back({0, temp-1}); } } sort(vc.begin(), vc.end()); for(int i=0; i<vc.size(); i++){ LL e=vc[i].first, r=vc[i].second; ans+=(max(pv, vc[i].first)>vc[i].second?0:vc[i].second-max(pv, vc[i].first)+1); pv=max(vc[i].second+1, pv); } printf("%lld", ans); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 252 KB | Output is correct |
2 | Correct | 8 ms | 760 KB | Output is correct |
3 | Correct | 9 ms | 860 KB | Output is correct |
4 | Correct | 2 ms | 312 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 380 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 2 ms | 256 KB | Output is correct |
9 | Correct | 3 ms | 376 KB | Output is correct |
10 | Correct | 2 ms | 256 KB | Output is correct |
11 | Correct | 2 ms | 256 KB | Output is correct |
12 | Correct | 2 ms | 376 KB | Output is correct |
13 | Correct | 2 ms | 256 KB | Output is correct |
14 | Correct | 2 ms | 348 KB | Output is correct |
15 | Correct | 2 ms | 376 KB | Output is correct |
16 | Correct | 8 ms | 1016 KB | Output is correct |
17 | Correct | 65 ms | 3504 KB | Output is correct |
18 | Correct | 2 ms | 256 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 2 ms | 256 KB | Output is correct |
3 | Correct | 3 ms | 256 KB | Output is correct |
4 | Correct | 2 ms | 256 KB | Output is correct |
5 | Correct | 2 ms | 256 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 3 ms | 376 KB | Output is correct |
3 | Correct | 3 ms | 376 KB | Output is correct |
4 | Correct | 3 ms | 376 KB | Output is correct |
5 | Correct | 427 ms | 17668 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 548 ms | 17596 KB | Output is correct |
3 | Correct | 545 ms | 17656 KB | Output is correct |
4 | Correct | 532 ms | 17640 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 548 ms | 17596 KB | Output is correct |
3 | Correct | 545 ms | 17656 KB | Output is correct |
4 | Correct | 532 ms | 17640 KB | Output is correct |
5 | Correct | 2 ms | 256 KB | Output is correct |
6 | Correct | 541 ms | 17644 KB | Output is correct |
7 | Correct | 548 ms | 17556 KB | Output is correct |
8 | Correct | 548 ms | 17388 KB | Output is correct |
9 | Correct | 596 ms | 17244 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 548 ms | 17596 KB | Output is correct |
3 | Correct | 545 ms | 17656 KB | Output is correct |
4 | Correct | 532 ms | 17640 KB | Output is correct |
5 | Correct | 2 ms | 256 KB | Output is correct |
6 | Correct | 55 ms | 2644 KB | Output is correct |
7 | Correct | 61 ms | 2512 KB | Output is correct |
8 | Correct | 53 ms | 2536 KB | Output is correct |
9 | Correct | 56 ms | 2540 KB | Output is correct |
10 | Correct | 55 ms | 2448 KB | Output is correct |
11 | Correct | 58 ms | 2456 KB | Output is correct |
12 | Correct | 56 ms | 2540 KB | Output is correct |
13 | Correct | 59 ms | 2536 KB | Output is correct |
14 | Correct | 53 ms | 2512 KB | Output is correct |
15 | Correct | 61 ms | 2540 KB | Output is correct |
16 | Correct | 61 ms | 2592 KB | Output is correct |
17 | Correct | 60 ms | 2540 KB | Output is correct |
18 | Correct | 562 ms | 16924 KB | Output is correct |
19 | Correct | 541 ms | 16840 KB | Output is correct |
20 | Correct | 600 ms | 17308 KB | Output is correct |
21 | Correct | 61 ms | 2792 KB | Output is correct |
22 | Correct | 52 ms | 2796 KB | Output is correct |
23 | Correct | 214 ms | 8808 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 58 ms | 2536 KB | Output is correct |
3 | Correct | 59 ms | 2536 KB | Output is correct |
4 | Correct | 623 ms | 17120 KB | Output is correct |
5 | Correct | 58 ms | 2800 KB | Output is correct |
6 | Correct | 58 ms | 2764 KB | Output is correct |
7 | Correct | 58 ms | 2752 KB | Output is correct |
8 | Correct | 61 ms | 2512 KB | Output is correct |
9 | Correct | 57 ms | 2536 KB | Output is correct |
10 | Correct | 58 ms | 2436 KB | Output is correct |
11 | Correct | 59 ms | 2540 KB | Output is correct |
12 | Correct | 51 ms | 2512 KB | Output is correct |
13 | Correct | 59 ms | 2560 KB | Output is correct |
14 | Correct | 590 ms | 16992 KB | Output is correct |
15 | Correct | 59 ms | 2540 KB | Output is correct |
16 | Correct | 542 ms | 16896 KB | Output is correct |
17 | Correct | 534 ms | 16956 KB | Output is correct |
18 | Correct | 2 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 252 KB | Output is correct |
2 | Correct | 8 ms | 760 KB | Output is correct |
3 | Correct | 9 ms | 860 KB | Output is correct |
4 | Correct | 2 ms | 312 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 380 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 2 ms | 256 KB | Output is correct |
9 | Correct | 3 ms | 376 KB | Output is correct |
10 | Correct | 2 ms | 256 KB | Output is correct |
11 | Correct | 2 ms | 256 KB | Output is correct |
12 | Correct | 2 ms | 376 KB | Output is correct |
13 | Correct | 2 ms | 256 KB | Output is correct |
14 | Correct | 2 ms | 348 KB | Output is correct |
15 | Correct | 2 ms | 376 KB | Output is correct |
16 | Correct | 8 ms | 1016 KB | Output is correct |
17 | Correct | 65 ms | 3504 KB | Output is correct |
18 | Correct | 2 ms | 256 KB | Output is correct |
19 | Correct | 2 ms | 256 KB | Output is correct |
20 | Correct | 2 ms | 256 KB | Output is correct |
21 | Correct | 3 ms | 256 KB | Output is correct |
22 | Correct | 2 ms | 256 KB | Output is correct |
23 | Correct | 2 ms | 256 KB | Output is correct |
24 | Correct | 2 ms | 256 KB | Output is correct |
25 | Correct | 3 ms | 376 KB | Output is correct |
26 | Correct | 3 ms | 376 KB | Output is correct |
27 | Correct | 3 ms | 376 KB | Output is correct |
28 | Correct | 427 ms | 17668 KB | Output is correct |
29 | Correct | 2 ms | 256 KB | Output is correct |
30 | Correct | 548 ms | 17596 KB | Output is correct |
31 | Correct | 545 ms | 17656 KB | Output is correct |
32 | Correct | 532 ms | 17640 KB | Output is correct |
33 | Correct | 2 ms | 256 KB | Output is correct |
34 | Correct | 541 ms | 17644 KB | Output is correct |
35 | Correct | 548 ms | 17556 KB | Output is correct |
36 | Correct | 548 ms | 17388 KB | Output is correct |
37 | Correct | 596 ms | 17244 KB | Output is correct |
38 | Correct | 2 ms | 256 KB | Output is correct |
39 | Correct | 55 ms | 2644 KB | Output is correct |
40 | Correct | 61 ms | 2512 KB | Output is correct |
41 | Correct | 53 ms | 2536 KB | Output is correct |
42 | Correct | 56 ms | 2540 KB | Output is correct |
43 | Correct | 55 ms | 2448 KB | Output is correct |
44 | Correct | 58 ms | 2456 KB | Output is correct |
45 | Correct | 56 ms | 2540 KB | Output is correct |
46 | Correct | 59 ms | 2536 KB | Output is correct |
47 | Correct | 53 ms | 2512 KB | Output is correct |
48 | Correct | 61 ms | 2540 KB | Output is correct |
49 | Correct | 61 ms | 2592 KB | Output is correct |
50 | Correct | 60 ms | 2540 KB | Output is correct |
51 | Correct | 562 ms | 16924 KB | Output is correct |
52 | Correct | 541 ms | 16840 KB | Output is correct |
53 | Correct | 600 ms | 17308 KB | Output is correct |
54 | Correct | 61 ms | 2792 KB | Output is correct |
55 | Correct | 52 ms | 2796 KB | Output is correct |
56 | Correct | 214 ms | 8808 KB | Output is correct |
57 | Correct | 2 ms | 376 KB | Output is correct |
58 | Correct | 58 ms | 2536 KB | Output is correct |
59 | Correct | 59 ms | 2536 KB | Output is correct |
60 | Correct | 623 ms | 17120 KB | Output is correct |
61 | Correct | 58 ms | 2800 KB | Output is correct |
62 | Correct | 58 ms | 2764 KB | Output is correct |
63 | Correct | 58 ms | 2752 KB | Output is correct |
64 | Correct | 61 ms | 2512 KB | Output is correct |
65 | Correct | 57 ms | 2536 KB | Output is correct |
66 | Correct | 58 ms | 2436 KB | Output is correct |
67 | Correct | 59 ms | 2540 KB | Output is correct |
68 | Correct | 51 ms | 2512 KB | Output is correct |
69 | Correct | 59 ms | 2560 KB | Output is correct |
70 | Correct | 590 ms | 16992 KB | Output is correct |
71 | Correct | 59 ms | 2540 KB | Output is correct |
72 | Correct | 542 ms | 16896 KB | Output is correct |
73 | Correct | 534 ms | 16956 KB | Output is correct |
74 | Correct | 2 ms | 376 KB | Output is correct |
75 | Correct | 2 ms | 256 KB | Output is correct |
76 | Correct | 2 ms | 376 KB | Output is correct |
77 | Correct | 2 ms | 256 KB | Output is correct |
78 | Correct | 2 ms | 256 KB | Output is correct |
79 | Correct | 7 ms | 1016 KB | Output is correct |
80 | Correct | 613 ms | 18864 KB | Output is correct |
81 | Correct | 612 ms | 18664 KB | Output is correct |
82 | Correct | 575 ms | 18828 KB | Output is correct |
83 | Correct | 573 ms | 18896 KB | Output is correct |
84 | Correct | 588 ms | 18896 KB | Output is correct |
85 | Correct | 739 ms | 18856 KB | Output is correct |
86 | Correct | 207 ms | 13152 KB | Output is correct |
87 | Correct | 2 ms | 372 KB | Output is correct |