# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
444240 | 2021-07-13T12:21:28 Z | qwerasdfzxcl | 이상한 기계 (APIO19_strange_device) | C++14 | 666 ms | 25456 KB |
#include <bits/stdc++.h> typedef __int128_t l128; typedef long long ll; using namespace std; int main(){ int n; ll x, y; scanf("%d %lld %lld", &n, &x, &y); l128 t = y; t *= x/__gcd(x, y+1); ll MOD = (ll)1e18+10; if (t<=(ll)1e18+10) MOD = t; //printf("%lld\n", MOD); vector<pair<ll, ll>> ran; for (int i=0;i<n;i++){ ll tmp1, tmp2; scanf("%lld %lld", &tmp1, &tmp2); if (tmp2-tmp1+1>=MOD) {printf("%lld\n", MOD); return 0;} tmp2++; tmp1 %= MOD, tmp2 %= MOD; if (tmp2<tmp1){ ran.emplace_back(tmp1, MOD); ran.emplace_back(0, tmp2); } else ran.emplace_back(tmp1, tmp2); } sort(ran.begin(), ran.end()); ll ans = 0; pair<ll, ll> cur = {0, 0}; n = ran.size(); for (int i=0;i<n;i++){ if (cur.first<=ran[i].first && ran[i].first<=cur.second){ ans += max(ran[i].second-cur.second, 0LL); cur.second = max(cur.second, ran[i].second); } else{ ans += ran[i].second-ran[i].first; cur = ran[i]; } } printf("%lld\n", ans); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 5 ms | 588 KB | Output is correct |
3 | Correct | 6 ms | 972 KB | Output is correct |
4 | Correct | 1 ms | 204 KB | Output is correct |
5 | Correct | 1 ms | 204 KB | Output is correct |
6 | Correct | 0 ms | 204 KB | Output is correct |
7 | Correct | 0 ms | 204 KB | Output is correct |
8 | Correct | 1 ms | 288 KB | Output is correct |
9 | Correct | 0 ms | 204 KB | Output is correct |
10 | Correct | 0 ms | 204 KB | Output is correct |
11 | Correct | 0 ms | 204 KB | Output is correct |
12 | Correct | 1 ms | 296 KB | Output is correct |
13 | Correct | 1 ms | 204 KB | Output is correct |
14 | Correct | 0 ms | 204 KB | Output is correct |
15 | Correct | 1 ms | 204 KB | Output is correct |
16 | Correct | 6 ms | 972 KB | Output is correct |
17 | Correct | 55 ms | 5584 KB | Output is correct |
18 | Correct | 1 ms | 204 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 0 ms | 204 KB | Output is correct |
3 | Correct | 0 ms | 204 KB | Output is correct |
4 | Correct | 0 ms | 204 KB | Output is correct |
5 | Correct | 1 ms | 204 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 332 KB | Output is correct |
4 | Correct | 1 ms | 332 KB | Output is correct |
5 | Correct | 366 ms | 17000 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 506 ms | 16736 KB | Output is correct |
3 | Correct | 499 ms | 16768 KB | Output is correct |
4 | Correct | 496 ms | 16808 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 506 ms | 16736 KB | Output is correct |
3 | Correct | 499 ms | 16768 KB | Output is correct |
4 | Correct | 496 ms | 16808 KB | Output is correct |
5 | Correct | 1 ms | 204 KB | Output is correct |
6 | Correct | 512 ms | 16820 KB | Output is correct |
7 | Correct | 511 ms | 16916 KB | Output is correct |
8 | Correct | 509 ms | 16828 KB | Output is correct |
9 | Correct | 557 ms | 16820 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 506 ms | 16736 KB | Output is correct |
3 | Correct | 499 ms | 16768 KB | Output is correct |
4 | Correct | 496 ms | 16808 KB | Output is correct |
5 | Correct | 1 ms | 204 KB | Output is correct |
6 | Correct | 50 ms | 2476 KB | Output is correct |
7 | Correct | 53 ms | 2432 KB | Output is correct |
8 | Correct | 51 ms | 2380 KB | Output is correct |
9 | Correct | 52 ms | 2576 KB | Output is correct |
10 | Correct | 49 ms | 2472 KB | Output is correct |
11 | Correct | 51 ms | 2408 KB | Output is correct |
12 | Correct | 49 ms | 2464 KB | Output is correct |
13 | Correct | 66 ms | 2428 KB | Output is correct |
14 | Correct | 49 ms | 2364 KB | Output is correct |
15 | Correct | 55 ms | 2388 KB | Output is correct |
16 | Correct | 55 ms | 5612 KB | Output is correct |
17 | Correct | 52 ms | 5608 KB | Output is correct |
18 | Correct | 511 ms | 25244 KB | Output is correct |
19 | Correct | 508 ms | 25172 KB | Output is correct |
20 | Correct | 625 ms | 25180 KB | Output is correct |
21 | Correct | 55 ms | 5668 KB | Output is correct |
22 | Correct | 49 ms | 5632 KB | Output is correct |
23 | Correct | 166 ms | 18420 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 54 ms | 2416 KB | Output is correct |
3 | Correct | 53 ms | 2384 KB | Output is correct |
4 | Correct | 637 ms | 16752 KB | Output is correct |
5 | Correct | 52 ms | 2492 KB | Output is correct |
6 | Correct | 52 ms | 2356 KB | Output is correct |
7 | Correct | 52 ms | 2436 KB | Output is correct |
8 | Correct | 58 ms | 2448 KB | Output is correct |
9 | Correct | 52 ms | 2444 KB | Output is correct |
10 | Correct | 68 ms | 2388 KB | Output is correct |
11 | Correct | 80 ms | 2388 KB | Output is correct |
12 | Correct | 51 ms | 2408 KB | Output is correct |
13 | Correct | 55 ms | 2380 KB | Output is correct |
14 | Correct | 579 ms | 16740 KB | Output is correct |
15 | Correct | 58 ms | 5656 KB | Output is correct |
16 | Correct | 562 ms | 25256 KB | Output is correct |
17 | Correct | 512 ms | 25220 KB | Output is correct |
18 | Correct | 0 ms | 204 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 5 ms | 588 KB | Output is correct |
3 | Correct | 6 ms | 972 KB | Output is correct |
4 | Correct | 1 ms | 204 KB | Output is correct |
5 | Correct | 1 ms | 204 KB | Output is correct |
6 | Correct | 0 ms | 204 KB | Output is correct |
7 | Correct | 0 ms | 204 KB | Output is correct |
8 | Correct | 1 ms | 288 KB | Output is correct |
9 | Correct | 0 ms | 204 KB | Output is correct |
10 | Correct | 0 ms | 204 KB | Output is correct |
11 | Correct | 0 ms | 204 KB | Output is correct |
12 | Correct | 1 ms | 296 KB | Output is correct |
13 | Correct | 1 ms | 204 KB | Output is correct |
14 | Correct | 0 ms | 204 KB | Output is correct |
15 | Correct | 1 ms | 204 KB | Output is correct |
16 | Correct | 6 ms | 972 KB | Output is correct |
17 | Correct | 55 ms | 5584 KB | Output is correct |
18 | Correct | 1 ms | 204 KB | Output is correct |
19 | Correct | 1 ms | 204 KB | Output is correct |
20 | Correct | 0 ms | 204 KB | Output is correct |
21 | Correct | 0 ms | 204 KB | Output is correct |
22 | Correct | 0 ms | 204 KB | Output is correct |
23 | Correct | 1 ms | 204 KB | Output is correct |
24 | Correct | 0 ms | 204 KB | Output is correct |
25 | Correct | 1 ms | 204 KB | Output is correct |
26 | Correct | 1 ms | 332 KB | Output is correct |
27 | Correct | 1 ms | 332 KB | Output is correct |
28 | Correct | 366 ms | 17000 KB | Output is correct |
29 | Correct | 0 ms | 204 KB | Output is correct |
30 | Correct | 506 ms | 16736 KB | Output is correct |
31 | Correct | 499 ms | 16768 KB | Output is correct |
32 | Correct | 496 ms | 16808 KB | Output is correct |
33 | Correct | 1 ms | 204 KB | Output is correct |
34 | Correct | 512 ms | 16820 KB | Output is correct |
35 | Correct | 511 ms | 16916 KB | Output is correct |
36 | Correct | 509 ms | 16828 KB | Output is correct |
37 | Correct | 557 ms | 16820 KB | Output is correct |
38 | Correct | 1 ms | 204 KB | Output is correct |
39 | Correct | 50 ms | 2476 KB | Output is correct |
40 | Correct | 53 ms | 2432 KB | Output is correct |
41 | Correct | 51 ms | 2380 KB | Output is correct |
42 | Correct | 52 ms | 2576 KB | Output is correct |
43 | Correct | 49 ms | 2472 KB | Output is correct |
44 | Correct | 51 ms | 2408 KB | Output is correct |
45 | Correct | 49 ms | 2464 KB | Output is correct |
46 | Correct | 66 ms | 2428 KB | Output is correct |
47 | Correct | 49 ms | 2364 KB | Output is correct |
48 | Correct | 55 ms | 2388 KB | Output is correct |
49 | Correct | 55 ms | 5612 KB | Output is correct |
50 | Correct | 52 ms | 5608 KB | Output is correct |
51 | Correct | 511 ms | 25244 KB | Output is correct |
52 | Correct | 508 ms | 25172 KB | Output is correct |
53 | Correct | 625 ms | 25180 KB | Output is correct |
54 | Correct | 55 ms | 5668 KB | Output is correct |
55 | Correct | 49 ms | 5632 KB | Output is correct |
56 | Correct | 166 ms | 18420 KB | Output is correct |
57 | Correct | 0 ms | 204 KB | Output is correct |
58 | Correct | 54 ms | 2416 KB | Output is correct |
59 | Correct | 53 ms | 2384 KB | Output is correct |
60 | Correct | 637 ms | 16752 KB | Output is correct |
61 | Correct | 52 ms | 2492 KB | Output is correct |
62 | Correct | 52 ms | 2356 KB | Output is correct |
63 | Correct | 52 ms | 2436 KB | Output is correct |
64 | Correct | 58 ms | 2448 KB | Output is correct |
65 | Correct | 52 ms | 2444 KB | Output is correct |
66 | Correct | 68 ms | 2388 KB | Output is correct |
67 | Correct | 80 ms | 2388 KB | Output is correct |
68 | Correct | 51 ms | 2408 KB | Output is correct |
69 | Correct | 55 ms | 2380 KB | Output is correct |
70 | Correct | 579 ms | 16740 KB | Output is correct |
71 | Correct | 58 ms | 5656 KB | Output is correct |
72 | Correct | 562 ms | 25256 KB | Output is correct |
73 | Correct | 512 ms | 25220 KB | Output is correct |
74 | Correct | 0 ms | 204 KB | Output is correct |
75 | Correct | 0 ms | 204 KB | Output is correct |
76 | Correct | 0 ms | 204 KB | Output is correct |
77 | Correct | 0 ms | 204 KB | Output is correct |
78 | Correct | 0 ms | 204 KB | Output is correct |
79 | Correct | 7 ms | 972 KB | Output is correct |
80 | Correct | 646 ms | 25456 KB | Output is correct |
81 | Correct | 666 ms | 25248 KB | Output is correct |
82 | Correct | 551 ms | 25152 KB | Output is correct |
83 | Correct | 539 ms | 25360 KB | Output is correct |
84 | Correct | 562 ms | 25204 KB | Output is correct |
85 | Correct | 549 ms | 25244 KB | Output is correct |
86 | Correct | 162 ms | 18372 KB | Output is correct |
87 | Correct | 0 ms | 204 KB | Output is correct |