답안 #361922

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
361922 2021-02-01T07:03:12 Z parsabahrami 이상한 기계 (APIO19_strange_device) C++17
100 / 100
822 ms 81132 KB
// Call my Name and Save me from The Dark
#include <bits/stdc++.h>
 
using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pii;
 
#define SZ(x)                       (int) x.size()
#define F                           first
#define S                           second

const int N = 1e6 + 10;
ll A, B; int n; set<pii> st;

int main() {
    scanf("%d%lld%lld", &n, &A, &B);
    ll tof = A / __gcd(A, B + 1), blk;
    if ((ll) 1e18 / B < tof) blk = (ll) 1e18 + 1;
    else blk = tof * B;
    for (int i = 1; i <= n; i++) {
        ll l, r; scanf("%lld%lld", &l, &r);
        if (r - l + 1 >= blk) return !printf("%lld\n", blk);
        if (l % blk <= r % blk) st.insert({l % blk, -(r % blk)});
        else st.insert({0, -(r % blk)}), st.insert({l % blk, -(blk - 1)});
    }
    ll mx = -1, ret = 0;
    for (pii x : st) {
        ret += max(0ll, -x.S - max(mx + 1, x.F) + 1);
        mx = max(mx, -x.S);
    }
    printf("%lld\n", ret);
    return 0;
}

Compilation message

strange_device.cpp: In function 'int main()':
strange_device.cpp:17:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   17 |     scanf("%d%lld%lld", &n, &A, &B);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
strange_device.cpp:22:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   22 |         ll l, r; scanf("%lld%lld", &l, &r);
      |                  ~~~~~^~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 7 ms 876 KB Output is correct
3 Correct 11 ms 1260 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 640 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 7 ms 1260 KB Output is correct
17 Correct 70 ms 7916 KB Output is correct
18 Correct 0 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 327 ms 1644 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 710 ms 62956 KB Output is correct
3 Correct 822 ms 64236 KB Output is correct
4 Correct 723 ms 64236 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 710 ms 62956 KB Output is correct
3 Correct 822 ms 64236 KB Output is correct
4 Correct 723 ms 64236 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 722 ms 64196 KB Output is correct
7 Correct 757 ms 64380 KB Output is correct
8 Correct 728 ms 64332 KB Output is correct
9 Correct 725 ms 64236 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 710 ms 62956 KB Output is correct
3 Correct 822 ms 64236 KB Output is correct
4 Correct 723 ms 64236 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 66 ms 7788 KB Output is correct
7 Correct 67 ms 7908 KB Output is correct
8 Correct 69 ms 7788 KB Output is correct
9 Correct 78 ms 7916 KB Output is correct
10 Correct 66 ms 7916 KB Output is correct
11 Correct 66 ms 7788 KB Output is correct
12 Correct 67 ms 7788 KB Output is correct
13 Correct 72 ms 7788 KB Output is correct
14 Correct 67 ms 7788 KB Output is correct
15 Correct 73 ms 7788 KB Output is correct
16 Correct 69 ms 7788 KB Output is correct
17 Correct 67 ms 7788 KB Output is correct
18 Correct 707 ms 64236 KB Output is correct
19 Correct 730 ms 64044 KB Output is correct
20 Correct 738 ms 64088 KB Output is correct
21 Correct 68 ms 7660 KB Output is correct
22 Correct 69 ms 7660 KB Output is correct
23 Correct 142 ms 1388 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 69 ms 6508 KB Output is correct
3 Correct 71 ms 7660 KB Output is correct
4 Correct 744 ms 63980 KB Output is correct
5 Correct 70 ms 7532 KB Output is correct
6 Correct 73 ms 7532 KB Output is correct
7 Correct 72 ms 7660 KB Output is correct
8 Correct 81 ms 7660 KB Output is correct
9 Correct 69 ms 7532 KB Output is correct
10 Correct 68 ms 7532 KB Output is correct
11 Correct 69 ms 7532 KB Output is correct
12 Correct 70 ms 7660 KB Output is correct
13 Correct 72 ms 7532 KB Output is correct
14 Correct 784 ms 63680 KB Output is correct
15 Correct 68 ms 7276 KB Output is correct
16 Correct 717 ms 63632 KB Output is correct
17 Correct 728 ms 63812 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 7 ms 876 KB Output is correct
3 Correct 11 ms 1260 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 640 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 7 ms 1260 KB Output is correct
17 Correct 70 ms 7916 KB Output is correct
18 Correct 0 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
22 Correct 1 ms 364 KB Output is correct
23 Correct 1 ms 364 KB Output is correct
24 Correct 0 ms 364 KB Output is correct
25 Correct 1 ms 364 KB Output is correct
26 Correct 1 ms 364 KB Output is correct
27 Correct 1 ms 364 KB Output is correct
28 Correct 327 ms 1644 KB Output is correct
29 Correct 1 ms 364 KB Output is correct
30 Correct 710 ms 62956 KB Output is correct
31 Correct 822 ms 64236 KB Output is correct
32 Correct 723 ms 64236 KB Output is correct
33 Correct 1 ms 364 KB Output is correct
34 Correct 722 ms 64196 KB Output is correct
35 Correct 757 ms 64380 KB Output is correct
36 Correct 728 ms 64332 KB Output is correct
37 Correct 725 ms 64236 KB Output is correct
38 Correct 1 ms 364 KB Output is correct
39 Correct 66 ms 7788 KB Output is correct
40 Correct 67 ms 7908 KB Output is correct
41 Correct 69 ms 7788 KB Output is correct
42 Correct 78 ms 7916 KB Output is correct
43 Correct 66 ms 7916 KB Output is correct
44 Correct 66 ms 7788 KB Output is correct
45 Correct 67 ms 7788 KB Output is correct
46 Correct 72 ms 7788 KB Output is correct
47 Correct 67 ms 7788 KB Output is correct
48 Correct 73 ms 7788 KB Output is correct
49 Correct 69 ms 7788 KB Output is correct
50 Correct 67 ms 7788 KB Output is correct
51 Correct 707 ms 64236 KB Output is correct
52 Correct 730 ms 64044 KB Output is correct
53 Correct 738 ms 64088 KB Output is correct
54 Correct 68 ms 7660 KB Output is correct
55 Correct 69 ms 7660 KB Output is correct
56 Correct 142 ms 1388 KB Output is correct
57 Correct 1 ms 364 KB Output is correct
58 Correct 69 ms 6508 KB Output is correct
59 Correct 71 ms 7660 KB Output is correct
60 Correct 744 ms 63980 KB Output is correct
61 Correct 70 ms 7532 KB Output is correct
62 Correct 73 ms 7532 KB Output is correct
63 Correct 72 ms 7660 KB Output is correct
64 Correct 81 ms 7660 KB Output is correct
65 Correct 69 ms 7532 KB Output is correct
66 Correct 68 ms 7532 KB Output is correct
67 Correct 69 ms 7532 KB Output is correct
68 Correct 70 ms 7660 KB Output is correct
69 Correct 72 ms 7532 KB Output is correct
70 Correct 784 ms 63680 KB Output is correct
71 Correct 68 ms 7276 KB Output is correct
72 Correct 717 ms 63632 KB Output is correct
73 Correct 728 ms 63812 KB Output is correct
74 Correct 1 ms 364 KB Output is correct
75 Correct 1 ms 364 KB Output is correct
76 Correct 1 ms 364 KB Output is correct
77 Correct 1 ms 364 KB Output is correct
78 Correct 1 ms 364 KB Output is correct
79 Correct 7 ms 1260 KB Output is correct
80 Correct 757 ms 72940 KB Output is correct
81 Correct 733 ms 72936 KB Output is correct
82 Correct 752 ms 72940 KB Output is correct
83 Correct 757 ms 81132 KB Output is correct
84 Correct 770 ms 78096 KB Output is correct
85 Correct 734 ms 77676 KB Output is correct
86 Correct 140 ms 12780 KB Output is correct
87 Correct 1 ms 364 KB Output is correct