답안 #225965

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
225965 2020-04-22T06:45:42 Z BeanZ 이상한 기계 (APIO19_strange_device) C++14
100 / 100
923 ms 100468 KB
#include <bits/stdc++.h>
using namespace std;

#define ull unsigned long long
#define endl '\n'
#define ll long long
const int N = 1e6 + 5;
const ll inf = 2e18;
int main(){
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        if (fopen("VLJUM.INP", "r")){
                freopen("VLJUM.INP", "r", stdin);
                freopen("VLJUM.OUT", "w", stdout);
        }
        ll n;
        ll a, b;
        cin >> n >> a >> b;
        ll m = a / __gcd(a, b + 1);
        m = (inf / m < b ? inf : b * m);
        map<ll, ll> mem;
        for (int i = 1; i <= n; i++) {
            ll l, r;
            cin >> l >> r;
            r++;
            if (r - l >= m) {
                    cout << m << endl;
                    return 0;
            }
            l %= m;
            r %= m;
            if (l < r){
                    mem[l]++;
                    mem[r]--;
            }
            else {
                    mem[0]++;
                    mem[r]--;
                    mem[l]++;
                    mem[m]--;
            }
        }
        ll cur = 0, cnt = 0;
        ll now = 0;
        for (auto j : mem) {
            cnt += (now > 0) * (j.first - cur);
            cur = j.first;
            now += j.second;
        }
        cout << cnt << endl;
}
/*
*/

Compilation message

strange_device.cpp: In function 'int main()':
strange_device.cpp:14:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
                 freopen("VLJUM.INP", "r", stdin);
                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
strange_device.cpp:15:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
                 freopen("VLJUM.OUT", "w", stdout);
                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 11 ms 1408 KB Output is correct
3 Correct 11 ms 1408 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 256 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 4 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 12 ms 1408 KB Output is correct
17 Correct 83 ms 10488 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 5 ms 512 KB Output is correct
3 Correct 6 ms 512 KB Output is correct
4 Correct 5 ms 512 KB Output is correct
5 Correct 357 ms 25592 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 790 ms 75260 KB Output is correct
3 Correct 826 ms 100224 KB Output is correct
4 Correct 891 ms 100400 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 790 ms 75260 KB Output is correct
3 Correct 826 ms 100224 KB Output is correct
4 Correct 891 ms 100400 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 832 ms 100212 KB Output is correct
7 Correct 854 ms 100212 KB Output is correct
8 Correct 834 ms 100396 KB Output is correct
9 Correct 917 ms 100172 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 790 ms 75260 KB Output is correct
3 Correct 826 ms 100224 KB Output is correct
4 Correct 891 ms 100400 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 72 ms 10304 KB Output is correct
7 Correct 77 ms 10360 KB Output is correct
8 Correct 80 ms 10360 KB Output is correct
9 Correct 83 ms 10360 KB Output is correct
10 Correct 78 ms 10360 KB Output is correct
11 Correct 77 ms 10364 KB Output is correct
12 Correct 79 ms 10360 KB Output is correct
13 Correct 87 ms 10360 KB Output is correct
14 Correct 76 ms 10360 KB Output is correct
15 Correct 91 ms 10488 KB Output is correct
16 Correct 91 ms 10360 KB Output is correct
17 Correct 82 ms 10360 KB Output is correct
18 Correct 798 ms 100212 KB Output is correct
19 Correct 866 ms 100212 KB Output is correct
20 Correct 872 ms 100212 KB Output is correct
21 Correct 89 ms 10360 KB Output is correct
22 Correct 79 ms 10376 KB Output is correct
23 Correct 159 ms 12920 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 90 ms 10360 KB Output is correct
3 Correct 90 ms 10436 KB Output is correct
4 Correct 894 ms 100356 KB Output is correct
5 Correct 90 ms 10360 KB Output is correct
6 Correct 90 ms 10316 KB Output is correct
7 Correct 93 ms 10488 KB Output is correct
8 Correct 86 ms 10360 KB Output is correct
9 Correct 89 ms 10360 KB Output is correct
10 Correct 81 ms 10360 KB Output is correct
11 Correct 87 ms 10360 KB Output is correct
12 Correct 84 ms 10360 KB Output is correct
13 Correct 92 ms 10364 KB Output is correct
14 Correct 920 ms 100204 KB Output is correct
15 Correct 74 ms 10360 KB Output is correct
16 Correct 803 ms 100168 KB Output is correct
17 Correct 796 ms 100240 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 11 ms 1408 KB Output is correct
3 Correct 11 ms 1408 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 256 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 4 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 12 ms 1408 KB Output is correct
17 Correct 83 ms 10488 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
21 Correct 4 ms 384 KB Output is correct
22 Correct 4 ms 384 KB Output is correct
23 Correct 5 ms 384 KB Output is correct
24 Correct 4 ms 384 KB Output is correct
25 Correct 5 ms 512 KB Output is correct
26 Correct 6 ms 512 KB Output is correct
27 Correct 5 ms 512 KB Output is correct
28 Correct 357 ms 25592 KB Output is correct
29 Correct 5 ms 384 KB Output is correct
30 Correct 790 ms 75260 KB Output is correct
31 Correct 826 ms 100224 KB Output is correct
32 Correct 891 ms 100400 KB Output is correct
33 Correct 5 ms 384 KB Output is correct
34 Correct 832 ms 100212 KB Output is correct
35 Correct 854 ms 100212 KB Output is correct
36 Correct 834 ms 100396 KB Output is correct
37 Correct 917 ms 100172 KB Output is correct
38 Correct 4 ms 384 KB Output is correct
39 Correct 72 ms 10304 KB Output is correct
40 Correct 77 ms 10360 KB Output is correct
41 Correct 80 ms 10360 KB Output is correct
42 Correct 83 ms 10360 KB Output is correct
43 Correct 78 ms 10360 KB Output is correct
44 Correct 77 ms 10364 KB Output is correct
45 Correct 79 ms 10360 KB Output is correct
46 Correct 87 ms 10360 KB Output is correct
47 Correct 76 ms 10360 KB Output is correct
48 Correct 91 ms 10488 KB Output is correct
49 Correct 91 ms 10360 KB Output is correct
50 Correct 82 ms 10360 KB Output is correct
51 Correct 798 ms 100212 KB Output is correct
52 Correct 866 ms 100212 KB Output is correct
53 Correct 872 ms 100212 KB Output is correct
54 Correct 89 ms 10360 KB Output is correct
55 Correct 79 ms 10376 KB Output is correct
56 Correct 159 ms 12920 KB Output is correct
57 Correct 5 ms 384 KB Output is correct
58 Correct 90 ms 10360 KB Output is correct
59 Correct 90 ms 10436 KB Output is correct
60 Correct 894 ms 100356 KB Output is correct
61 Correct 90 ms 10360 KB Output is correct
62 Correct 90 ms 10316 KB Output is correct
63 Correct 93 ms 10488 KB Output is correct
64 Correct 86 ms 10360 KB Output is correct
65 Correct 89 ms 10360 KB Output is correct
66 Correct 81 ms 10360 KB Output is correct
67 Correct 87 ms 10360 KB Output is correct
68 Correct 84 ms 10360 KB Output is correct
69 Correct 92 ms 10364 KB Output is correct
70 Correct 920 ms 100204 KB Output is correct
71 Correct 74 ms 10360 KB Output is correct
72 Correct 803 ms 100168 KB Output is correct
73 Correct 796 ms 100240 KB Output is correct
74 Correct 5 ms 384 KB Output is correct
75 Correct 4 ms 384 KB Output is correct
76 Correct 5 ms 384 KB Output is correct
77 Correct 5 ms 384 KB Output is correct
78 Correct 5 ms 512 KB Output is correct
79 Correct 14 ms 1408 KB Output is correct
80 Correct 901 ms 100376 KB Output is correct
81 Correct 880 ms 100468 KB Output is correct
82 Correct 906 ms 100340 KB Output is correct
83 Correct 921 ms 100212 KB Output is correct
84 Correct 923 ms 100236 KB Output is correct
85 Correct 843 ms 100212 KB Output is correct
86 Correct 153 ms 12920 KB Output is correct
87 Correct 5 ms 384 KB Output is correct