# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
582928 | 2022-06-24T15:17:36 Z | groshi | Strange Device (APIO19_strange_device) | C++17 | 557 ms | 77788 KB |
#include<iostream> #include<vector> #include<algorithm> #include<utility> #include<string> #include<queue> using namespace std; #define int long long vector<pair<int,int> > Q,pom; int32_t main() { cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0); long long n,a,b,x,y; cin>>n>>a>>b; for(int i=1;i<=n;i++) { cin>>x>>y; Q.push_back({x,y}); } sort(Q.begin(),Q.end()); bool cale=0; int cos=a*b/__gcd(a,b+1); if(1e18/a>=b) for(int i=0;i<Q.size();i++) { if(Q[i].second-Q[i].first+1>=cos) cale=1; } else{ int suma=0; for(int i=0;i<Q.size();i++) suma+=(Q[i].second-Q[i].first+1); cout<<suma; return 0; } if(cale==1) { cout<<a*b; return 0; } for(int i=0;i<Q.size();i++) { if(Q[i].second%cos>=Q[i].first%cos) pom.push_back({Q[i].first%cos,Q[i].second%cos}); else{ pom.push_back({Q[i].first%cos,cos-1}); pom.push_back({0,Q[i].second%cos}); } } sort(pom.begin(),pom.end()); int wynik=0; int maxx=-1; maxx=pom[0].second; int pocz=pom[0].first; for(int i=1;i<pom.size();i++) { if(pom[i].first>maxx) { wynik+=maxx-pocz+1; pocz=pom[i].first; maxx=pom[i].second; } else maxx=max(maxx,pom[i].second); } wynik+=maxx-pocz+1; cout<<wynik; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 6 ms | 856 KB | Output is correct |
3 | Correct | 4 ms | 856 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
10 | Correct | 1 ms | 320 KB | Output is correct |
11 | Correct | 1 ms | 316 KB | Output is correct |
12 | Correct | 1 ms | 320 KB | Output is correct |
13 | Correct | 1 ms | 212 KB | Output is correct |
14 | Correct | 1 ms | 212 KB | Output is correct |
15 | Correct | 1 ms | 212 KB | Output is correct |
16 | Correct | 6 ms | 1176 KB | Output is correct |
17 | Correct | 57 ms | 8644 KB | Output is correct |
18 | Correct | 1 ms | 212 KB | Output is correct |
# | 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 | 0 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 | 358 ms | 40560 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 451 ms | 40696 KB | Output is correct |
3 | Correct | 438 ms | 40544 KB | Output is correct |
4 | Correct | 500 ms | 77704 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 451 ms | 40696 KB | Output is correct |
3 | Correct | 438 ms | 40544 KB | Output is correct |
4 | Correct | 500 ms | 77704 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 490 ms | 77652 KB | Output is correct |
7 | Correct | 483 ms | 77756 KB | Output is correct |
8 | Correct | 466 ms | 77728 KB | Output is correct |
9 | Correct | 499 ms | 77672 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 451 ms | 40696 KB | Output is correct |
3 | Correct | 438 ms | 40544 KB | Output is correct |
4 | Correct | 500 ms | 77704 KB | Output is correct |
5 | Correct | 1 ms | 312 KB | Output is correct |
6 | Correct | 52 ms | 8620 KB | Output is correct |
7 | Correct | 52 ms | 8632 KB | Output is correct |
8 | Correct | 46 ms | 8644 KB | Output is correct |
9 | Correct | 49 ms | 8648 KB | Output is correct |
10 | Correct | 45 ms | 8688 KB | Output is correct |
11 | Correct | 53 ms | 8580 KB | Output is correct |
12 | Correct | 49 ms | 8624 KB | Output is correct |
13 | Correct | 48 ms | 8576 KB | Output is correct |
14 | Correct | 42 ms | 8716 KB | Output is correct |
15 | Correct | 51 ms | 8568 KB | Output is correct |
16 | Correct | 48 ms | 8664 KB | Output is correct |
17 | Correct | 52 ms | 8652 KB | Output is correct |
18 | Correct | 455 ms | 77720 KB | Output is correct |
19 | Correct | 453 ms | 77760 KB | Output is correct |
20 | Correct | 533 ms | 77664 KB | Output is correct |
21 | Correct | 47 ms | 8620 KB | Output is correct |
22 | Correct | 45 ms | 8608 KB | Output is correct |
23 | Correct | 162 ms | 30520 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 49 ms | 4960 KB | Output is correct |
3 | Correct | 44 ms | 4916 KB | Output is correct |
4 | Correct | 488 ms | 40480 KB | Output is correct |
5 | Correct | 48 ms | 4928 KB | Output is correct |
6 | Correct | 43 ms | 4904 KB | Output is correct |
7 | Correct | 43 ms | 4948 KB | Output is correct |
8 | Correct | 45 ms | 4896 KB | Output is correct |
9 | Correct | 47 ms | 4904 KB | Output is correct |
10 | Correct | 51 ms | 4920 KB | Output is correct |
11 | Correct | 54 ms | 4952 KB | Output is correct |
12 | Correct | 41 ms | 4936 KB | Output is correct |
13 | Correct | 43 ms | 4932 KB | Output is correct |
14 | Correct | 466 ms | 40628 KB | Output is correct |
15 | Correct | 48 ms | 4932 KB | Output is correct |
16 | Correct | 475 ms | 77720 KB | Output is correct |
17 | Correct | 493 ms | 77684 KB | Output is correct |
18 | Correct | 1 ms | 212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 6 ms | 856 KB | Output is correct |
3 | Correct | 4 ms | 856 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
10 | Correct | 1 ms | 320 KB | Output is correct |
11 | Correct | 1 ms | 316 KB | Output is correct |
12 | Correct | 1 ms | 320 KB | Output is correct |
13 | Correct | 1 ms | 212 KB | Output is correct |
14 | Correct | 1 ms | 212 KB | Output is correct |
15 | Correct | 1 ms | 212 KB | Output is correct |
16 | Correct | 6 ms | 1176 KB | Output is correct |
17 | Correct | 57 ms | 8644 KB | Output is correct |
18 | Correct | 1 ms | 212 KB | Output is correct |
19 | Correct | 0 ms | 212 KB | Output is correct |
20 | Correct | 0 ms | 212 KB | Output is correct |
21 | Correct | 0 ms | 212 KB | Output is correct |
22 | Correct | 0 ms | 212 KB | Output is correct |
23 | Correct | 0 ms | 212 KB | Output is correct |
24 | Correct | 0 ms | 212 KB | Output is correct |
25 | Correct | 1 ms | 340 KB | Output is correct |
26 | Correct | 1 ms | 340 KB | Output is correct |
27 | Correct | 1 ms | 340 KB | Output is correct |
28 | Correct | 358 ms | 40560 KB | Output is correct |
29 | Correct | 0 ms | 212 KB | Output is correct |
30 | Correct | 451 ms | 40696 KB | Output is correct |
31 | Correct | 438 ms | 40544 KB | Output is correct |
32 | Correct | 500 ms | 77704 KB | Output is correct |
33 | Correct | 1 ms | 212 KB | Output is correct |
34 | Correct | 490 ms | 77652 KB | Output is correct |
35 | Correct | 483 ms | 77756 KB | Output is correct |
36 | Correct | 466 ms | 77728 KB | Output is correct |
37 | Correct | 499 ms | 77672 KB | Output is correct |
38 | Correct | 1 ms | 312 KB | Output is correct |
39 | Correct | 52 ms | 8620 KB | Output is correct |
40 | Correct | 52 ms | 8632 KB | Output is correct |
41 | Correct | 46 ms | 8644 KB | Output is correct |
42 | Correct | 49 ms | 8648 KB | Output is correct |
43 | Correct | 45 ms | 8688 KB | Output is correct |
44 | Correct | 53 ms | 8580 KB | Output is correct |
45 | Correct | 49 ms | 8624 KB | Output is correct |
46 | Correct | 48 ms | 8576 KB | Output is correct |
47 | Correct | 42 ms | 8716 KB | Output is correct |
48 | Correct | 51 ms | 8568 KB | Output is correct |
49 | Correct | 48 ms | 8664 KB | Output is correct |
50 | Correct | 52 ms | 8652 KB | Output is correct |
51 | Correct | 455 ms | 77720 KB | Output is correct |
52 | Correct | 453 ms | 77760 KB | Output is correct |
53 | Correct | 533 ms | 77664 KB | Output is correct |
54 | Correct | 47 ms | 8620 KB | Output is correct |
55 | Correct | 45 ms | 8608 KB | Output is correct |
56 | Correct | 162 ms | 30520 KB | Output is correct |
57 | Correct | 0 ms | 212 KB | Output is correct |
58 | Correct | 49 ms | 4960 KB | Output is correct |
59 | Correct | 44 ms | 4916 KB | Output is correct |
60 | Correct | 488 ms | 40480 KB | Output is correct |
61 | Correct | 48 ms | 4928 KB | Output is correct |
62 | Correct | 43 ms | 4904 KB | Output is correct |
63 | Correct | 43 ms | 4948 KB | Output is correct |
64 | Correct | 45 ms | 4896 KB | Output is correct |
65 | Correct | 47 ms | 4904 KB | Output is correct |
66 | Correct | 51 ms | 4920 KB | Output is correct |
67 | Correct | 54 ms | 4952 KB | Output is correct |
68 | Correct | 41 ms | 4936 KB | Output is correct |
69 | Correct | 43 ms | 4932 KB | Output is correct |
70 | Correct | 466 ms | 40628 KB | Output is correct |
71 | Correct | 48 ms | 4932 KB | Output is correct |
72 | Correct | 475 ms | 77720 KB | Output is correct |
73 | Correct | 493 ms | 77684 KB | Output is correct |
74 | Correct | 1 ms | 212 KB | Output is correct |
75 | Correct | 1 ms | 212 KB | Output is correct |
76 | Correct | 1 ms | 212 KB | Output is correct |
77 | Correct | 1 ms | 212 KB | Output is correct |
78 | Correct | 1 ms | 212 KB | Output is correct |
79 | Correct | 6 ms | 1240 KB | Output is correct |
80 | Correct | 557 ms | 77644 KB | Output is correct |
81 | Correct | 554 ms | 77664 KB | Output is correct |
82 | Correct | 539 ms | 77776 KB | Output is correct |
83 | Correct | 539 ms | 77732 KB | Output is correct |
84 | Correct | 551 ms | 77788 KB | Output is correct |
85 | Correct | 505 ms | 77652 KB | Output is correct |
86 | Correct | 155 ms | 30460 KB | Output is correct |
87 | Correct | 1 ms | 212 KB | Output is correct |