답안 #723188

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
723188 2023-04-13T10:08:17 Z culver0412 이상한 기계 (APIO19_strange_device) C++17
100 / 100
1659 ms 28748 KB
#include<bits/stdc++.h>
using namespace std;

void bruh(int n){
    long long int ans=0;
    for(int i=0;i<n;i++){
        long long int l,r;
        cin >> l >> r;
        ans+=(r-l+1);
    }
    cout << ans << endl;
    return;
}

int main(){
    long long int n,a,b;
    cin >> n >> a >> b;
    long long int x=a/gcd(a,b+1);
    if(b<1e18*1.0/x){
        x*=b;
    }
    else{
        bruh(n);
        return 0;
    }
    vector<pair<long long int,long long int>> ranges;
    for(int i=0;i<n;i++){
        long long int l,r;
        cin >> l >> r;
        if(r-l+1>=x){
            cout << x << endl;
            return 0;
        }
        l%=x;
        r%=x;
        if(l<=r){
            ranges.push_back({l,r});
        }
        else{
            ranges.push_back({0,r});
            ranges.push_back({l,x-1});
        }
    }
    sort(ranges.begin(),ranges.end());
    long long int curl=ranges[0].first,curr=ranges[0].second,ans=0;
    for(int i=1;i<ranges.size();i++){
        pair<long long int,long long int> range=ranges[i];
        if(curr<range.first){
            ans+=(curr-curl+1);
            curl=range.first;
            curr=range.second;
        }
        else{
            curr=max(curr,range.second);
        }
    }
    ans+=(curr-curl+1);
    cout << ans << endl;
}

Compilation message

strange_device.cpp: In function 'int main()':
strange_device.cpp:46:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |     for(int i=1;i<ranges.size();i++){
      |                 ~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 18 ms 1012 KB Output is correct
3 Correct 19 ms 980 KB Output is correct
4 Correct 1 ms 300 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 300 KB Output is correct
10 Correct 1 ms 296 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 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 292 KB Output is correct
16 Correct 15 ms 1020 KB Output is correct
17 Correct 169 ms 3504 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 296 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 2 ms 340 KB Output is correct
3 Correct 2 ms 308 KB Output is correct
4 Correct 4 ms 340 KB Output is correct
5 Correct 1047 ms 16900 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1634 ms 16904 KB Output is correct
3 Correct 1599 ms 16888 KB Output is correct
4 Correct 1614 ms 17972 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1634 ms 16904 KB Output is correct
3 Correct 1599 ms 16888 KB Output is correct
4 Correct 1614 ms 17972 KB Output is correct
5 Correct 1 ms 300 KB Output is correct
6 Correct 1659 ms 17892 KB Output is correct
7 Correct 1416 ms 18016 KB Output is correct
8 Correct 1399 ms 17996 KB Output is correct
9 Correct 1469 ms 17900 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1634 ms 16904 KB Output is correct
3 Correct 1599 ms 16888 KB Output is correct
4 Correct 1614 ms 17972 KB Output is correct
5 Correct 1 ms 296 KB Output is correct
6 Correct 144 ms 3196 KB Output is correct
7 Correct 143 ms 3108 KB Output is correct
8 Correct 149 ms 3172 KB Output is correct
9 Correct 144 ms 3256 KB Output is correct
10 Correct 141 ms 3196 KB Output is correct
11 Correct 138 ms 3076 KB Output is correct
12 Correct 137 ms 3280 KB Output is correct
13 Correct 174 ms 3200 KB Output is correct
14 Correct 144 ms 3308 KB Output is correct
15 Correct 192 ms 2976 KB Output is correct
16 Correct 148 ms 3424 KB Output is correct
17 Correct 141 ms 3140 KB Output is correct
18 Correct 1424 ms 18020 KB Output is correct
19 Correct 1431 ms 18016 KB Output is correct
20 Correct 1463 ms 17940 KB Output is correct
21 Correct 139 ms 3252 KB Output is correct
22 Correct 174 ms 3324 KB Output is correct
23 Correct 441 ms 9624 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 149 ms 3700 KB Output is correct
3 Correct 145 ms 3764 KB Output is correct
4 Correct 1507 ms 16940 KB Output is correct
5 Correct 148 ms 3772 KB Output is correct
6 Correct 149 ms 3764 KB Output is correct
7 Correct 135 ms 3772 KB Output is correct
8 Correct 146 ms 3784 KB Output is correct
9 Correct 158 ms 3712 KB Output is correct
10 Correct 143 ms 3772 KB Output is correct
11 Correct 136 ms 3752 KB Output is correct
12 Correct 143 ms 3672 KB Output is correct
13 Correct 171 ms 3780 KB Output is correct
14 Correct 1501 ms 16824 KB Output is correct
15 Correct 138 ms 3772 KB Output is correct
16 Correct 1458 ms 17928 KB Output is correct
17 Correct 1432 ms 17928 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 18 ms 1012 KB Output is correct
3 Correct 19 ms 980 KB Output is correct
4 Correct 1 ms 300 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 300 KB Output is correct
10 Correct 1 ms 296 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 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 292 KB Output is correct
16 Correct 15 ms 1020 KB Output is correct
17 Correct 169 ms 3504 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 296 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 2 ms 340 KB Output is correct
26 Correct 2 ms 308 KB Output is correct
27 Correct 4 ms 340 KB Output is correct
28 Correct 1047 ms 16900 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 1634 ms 16904 KB Output is correct
31 Correct 1599 ms 16888 KB Output is correct
32 Correct 1614 ms 17972 KB Output is correct
33 Correct 1 ms 300 KB Output is correct
34 Correct 1659 ms 17892 KB Output is correct
35 Correct 1416 ms 18016 KB Output is correct
36 Correct 1399 ms 17996 KB Output is correct
37 Correct 1469 ms 17900 KB Output is correct
38 Correct 1 ms 296 KB Output is correct
39 Correct 144 ms 3196 KB Output is correct
40 Correct 143 ms 3108 KB Output is correct
41 Correct 149 ms 3172 KB Output is correct
42 Correct 144 ms 3256 KB Output is correct
43 Correct 141 ms 3196 KB Output is correct
44 Correct 138 ms 3076 KB Output is correct
45 Correct 137 ms 3280 KB Output is correct
46 Correct 174 ms 3200 KB Output is correct
47 Correct 144 ms 3308 KB Output is correct
48 Correct 192 ms 2976 KB Output is correct
49 Correct 148 ms 3424 KB Output is correct
50 Correct 141 ms 3140 KB Output is correct
51 Correct 1424 ms 18020 KB Output is correct
52 Correct 1431 ms 18016 KB Output is correct
53 Correct 1463 ms 17940 KB Output is correct
54 Correct 139 ms 3252 KB Output is correct
55 Correct 174 ms 3324 KB Output is correct
56 Correct 441 ms 9624 KB Output is correct
57 Correct 1 ms 212 KB Output is correct
58 Correct 149 ms 3700 KB Output is correct
59 Correct 145 ms 3764 KB Output is correct
60 Correct 1507 ms 16940 KB Output is correct
61 Correct 148 ms 3772 KB Output is correct
62 Correct 149 ms 3764 KB Output is correct
63 Correct 135 ms 3772 KB Output is correct
64 Correct 146 ms 3784 KB Output is correct
65 Correct 158 ms 3712 KB Output is correct
66 Correct 143 ms 3772 KB Output is correct
67 Correct 136 ms 3752 KB Output is correct
68 Correct 143 ms 3672 KB Output is correct
69 Correct 171 ms 3780 KB Output is correct
70 Correct 1501 ms 16824 KB Output is correct
71 Correct 138 ms 3772 KB Output is correct
72 Correct 1458 ms 17928 KB Output is correct
73 Correct 1432 ms 17928 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 15 ms 1024 KB Output is correct
80 Correct 1570 ms 28748 KB Output is correct
81 Correct 1519 ms 27956 KB Output is correct
82 Correct 1400 ms 27968 KB Output is correct
83 Correct 1512 ms 27848 KB Output is correct
84 Correct 1469 ms 27924 KB Output is correct
85 Correct 1497 ms 27968 KB Output is correct
86 Correct 453 ms 18396 KB Output is correct
87 Correct 1 ms 212 KB Output is correct