# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
981398 | 2024-05-13T06:57:08 Z | Amaarsaa | 이상한 기계 (APIO19_strange_device) | C++14 | 434 ms | 53940 KB |
#include<bits/stdc++.h> using namespace std; using ll = long long ; int main() { // freopen("moocast.in", "r", stdin); // freopen("moocast.out", "w", stdout); ios::sync_with_stdio(false); cin.tie(NULL); ll t, n, m, ans,l, a, b, s, lo, hi, mid, sum, x, y, r, p, i, j; cin >> n >> a >> b; s = __gcd(b + 1, a); s = a / s; if ( b > 1e18/s) { s= 0; for (i = 1; i <= n; i ++) { cin >> x >> y; s += (y -x + 1); } cout << s<< endl; return 0; } s = s * b; ans = 0; map < ll, ll > A; vector < pair <ll,ll > > v; for (i = 1; i <= n; i ++) { cin >> x >> y; if ( x / s == y / s) { v.push_back({x%s, y%s}); } else { if ( x / s + 1 == y / s) { v.push_back({x%s, s - 1}); v.push_back({0, y%s}); } else { cout << s << endl; return 0; } } } sort(v.begin(), v.end()); ll mx = -1; for (i = 0; i < v.size(); i ++) { if ( v[i].first <= mx) { ans += max(0ll, v[i].second - mx); } else ans += (v[i].second - v[i].first + 1); mx =max(mx, v[i].second); } cout << ans << endl; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 3 ms | 736 KB | Output is correct |
3 | Correct | 3 ms | 736 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 1 ms | 344 KB | Output is correct |
8 | Correct | 0 ms | 600 KB | Output is correct |
9 | Correct | 1 ms | 348 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
11 | Correct | 0 ms | 348 KB | Output is correct |
12 | Correct | 0 ms | 348 KB | Output is correct |
13 | Correct | 0 ms | 348 KB | Output is correct |
14 | Correct | 0 ms | 348 KB | Output is correct |
15 | Correct | 1 ms | 344 KB | Output is correct |
16 | Correct | 3 ms | 736 KB | Output is correct |
17 | Correct | 32 ms | 2568 KB | Output is correct |
18 | Correct | 0 ms | 344 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 348 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 1 ms | 344 KB | Output is correct |
4 | Correct | 1 ms | 348 KB | Output is correct |
5 | Correct | 216 ms | 17904 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 288 ms | 17916 KB | Output is correct |
3 | Correct | 281 ms | 18196 KB | Output is correct |
4 | Correct | 312 ms | 53328 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 288 ms | 17916 KB | Output is correct |
3 | Correct | 281 ms | 18196 KB | Output is correct |
4 | Correct | 312 ms | 53328 KB | Output is correct |
5 | Correct | 1 ms | 344 KB | Output is correct |
6 | Correct | 304 ms | 53544 KB | Output is correct |
7 | Correct | 313 ms | 53940 KB | Output is correct |
8 | Correct | 303 ms | 53488 KB | Output is correct |
9 | Correct | 357 ms | 53700 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 288 ms | 17916 KB | Output is correct |
3 | Correct | 281 ms | 18196 KB | Output is correct |
4 | Correct | 312 ms | 53328 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 29 ms | 5636 KB | Output is correct |
7 | Correct | 32 ms | 5836 KB | Output is correct |
8 | Correct | 32 ms | 5832 KB | Output is correct |
9 | Correct | 32 ms | 5636 KB | Output is correct |
10 | Correct | 34 ms | 6252 KB | Output is correct |
11 | Correct | 31 ms | 5844 KB | Output is correct |
12 | Correct | 29 ms | 5832 KB | Output is correct |
13 | Correct | 32 ms | 5812 KB | Output is correct |
14 | Correct | 30 ms | 5732 KB | Output is correct |
15 | Correct | 34 ms | 5832 KB | Output is correct |
16 | Correct | 32 ms | 5832 KB | Output is correct |
17 | Correct | 35 ms | 5676 KB | Output is correct |
18 | Correct | 311 ms | 52976 KB | Output is correct |
19 | Correct | 314 ms | 52948 KB | Output is correct |
20 | Correct | 326 ms | 52992 KB | Output is correct |
21 | Correct | 37 ms | 5708 KB | Output is correct |
22 | Correct | 32 ms | 5680 KB | Output is correct |
23 | Correct | 93 ms | 19232 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 33 ms | 2520 KB | Output is correct |
3 | Correct | 32 ms | 2520 KB | Output is correct |
4 | Correct | 434 ms | 17628 KB | Output is correct |
5 | Correct | 32 ms | 2520 KB | Output is correct |
6 | Correct | 31 ms | 2512 KB | Output is correct |
7 | Correct | 32 ms | 2520 KB | Output is correct |
8 | Correct | 35 ms | 2636 KB | Output is correct |
9 | Correct | 31 ms | 2520 KB | Output is correct |
10 | Correct | 38 ms | 2656 KB | Output is correct |
11 | Correct | 36 ms | 2672 KB | Output is correct |
12 | Correct | 28 ms | 2520 KB | Output is correct |
13 | Correct | 39 ms | 2520 KB | Output is correct |
14 | Correct | 338 ms | 17332 KB | Output is correct |
15 | Correct | 34 ms | 2508 KB | Output is correct |
16 | Correct | 291 ms | 18612 KB | Output is correct |
17 | Correct | 282 ms | 18820 KB | Output is correct |
18 | Correct | 0 ms | 344 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 3 ms | 736 KB | Output is correct |
3 | Correct | 3 ms | 736 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 1 ms | 344 KB | Output is correct |
8 | Correct | 0 ms | 600 KB | Output is correct |
9 | Correct | 1 ms | 348 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
11 | Correct | 0 ms | 348 KB | Output is correct |
12 | Correct | 0 ms | 348 KB | Output is correct |
13 | Correct | 0 ms | 348 KB | Output is correct |
14 | Correct | 0 ms | 348 KB | Output is correct |
15 | Correct | 1 ms | 344 KB | Output is correct |
16 | Correct | 3 ms | 736 KB | Output is correct |
17 | Correct | 32 ms | 2568 KB | Output is correct |
18 | Correct | 0 ms | 344 KB | Output is correct |
19 | Correct | 0 ms | 348 KB | Output is correct |
20 | Correct | 0 ms | 348 KB | Output is correct |
21 | Correct | 0 ms | 348 KB | Output is correct |
22 | Correct | 0 ms | 348 KB | Output is correct |
23 | Correct | 0 ms | 348 KB | Output is correct |
24 | Correct | 1 ms | 348 KB | Output is correct |
25 | Correct | 1 ms | 348 KB | Output is correct |
26 | Correct | 1 ms | 344 KB | Output is correct |
27 | Correct | 1 ms | 348 KB | Output is correct |
28 | Correct | 216 ms | 17904 KB | Output is correct |
29 | Correct | 0 ms | 348 KB | Output is correct |
30 | Correct | 288 ms | 17916 KB | Output is correct |
31 | Correct | 281 ms | 18196 KB | Output is correct |
32 | Correct | 312 ms | 53328 KB | Output is correct |
33 | Correct | 1 ms | 344 KB | Output is correct |
34 | Correct | 304 ms | 53544 KB | Output is correct |
35 | Correct | 313 ms | 53940 KB | Output is correct |
36 | Correct | 303 ms | 53488 KB | Output is correct |
37 | Correct | 357 ms | 53700 KB | Output is correct |
38 | Correct | 0 ms | 348 KB | Output is correct |
39 | Correct | 29 ms | 5636 KB | Output is correct |
40 | Correct | 32 ms | 5836 KB | Output is correct |
41 | Correct | 32 ms | 5832 KB | Output is correct |
42 | Correct | 32 ms | 5636 KB | Output is correct |
43 | Correct | 34 ms | 6252 KB | Output is correct |
44 | Correct | 31 ms | 5844 KB | Output is correct |
45 | Correct | 29 ms | 5832 KB | Output is correct |
46 | Correct | 32 ms | 5812 KB | Output is correct |
47 | Correct | 30 ms | 5732 KB | Output is correct |
48 | Correct | 34 ms | 5832 KB | Output is correct |
49 | Correct | 32 ms | 5832 KB | Output is correct |
50 | Correct | 35 ms | 5676 KB | Output is correct |
51 | Correct | 311 ms | 52976 KB | Output is correct |
52 | Correct | 314 ms | 52948 KB | Output is correct |
53 | Correct | 326 ms | 52992 KB | Output is correct |
54 | Correct | 37 ms | 5708 KB | Output is correct |
55 | Correct | 32 ms | 5680 KB | Output is correct |
56 | Correct | 93 ms | 19232 KB | Output is correct |
57 | Correct | 0 ms | 344 KB | Output is correct |
58 | Correct | 33 ms | 2520 KB | Output is correct |
59 | Correct | 32 ms | 2520 KB | Output is correct |
60 | Correct | 434 ms | 17628 KB | Output is correct |
61 | Correct | 32 ms | 2520 KB | Output is correct |
62 | Correct | 31 ms | 2512 KB | Output is correct |
63 | Correct | 32 ms | 2520 KB | Output is correct |
64 | Correct | 35 ms | 2636 KB | Output is correct |
65 | Correct | 31 ms | 2520 KB | Output is correct |
66 | Correct | 38 ms | 2656 KB | Output is correct |
67 | Correct | 36 ms | 2672 KB | Output is correct |
68 | Correct | 28 ms | 2520 KB | Output is correct |
69 | Correct | 39 ms | 2520 KB | Output is correct |
70 | Correct | 338 ms | 17332 KB | Output is correct |
71 | Correct | 34 ms | 2508 KB | Output is correct |
72 | Correct | 291 ms | 18612 KB | Output is correct |
73 | Correct | 282 ms | 18820 KB | Output is correct |
74 | Correct | 0 ms | 344 KB | Output is correct |
75 | Correct | 0 ms | 348 KB | Output is correct |
76 | Correct | 0 ms | 348 KB | Output is correct |
77 | Correct | 0 ms | 348 KB | Output is correct |
78 | Correct | 0 ms | 348 KB | Output is correct |
79 | Correct | 5 ms | 1088 KB | Output is correct |
80 | Correct | 342 ms | 53272 KB | Output is correct |
81 | Correct | 356 ms | 53312 KB | Output is correct |
82 | Correct | 332 ms | 53516 KB | Output is correct |
83 | Correct | 326 ms | 53004 KB | Output is correct |
84 | Correct | 338 ms | 53668 KB | Output is correct |
85 | Correct | 333 ms | 53052 KB | Output is correct |
86 | Correct | 109 ms | 19128 KB | Output is correct |
87 | Correct | 0 ms | 344 KB | Output is correct |