답안 #402081

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
402081 2021-05-11T09:37:41 Z Blobo2_Blobo2 이상한 기계 (APIO19_strange_device) C++14
100 / 100
591 ms 28248 KB
/*
Editor: Abdelrahman Hossam
Nickname: Blobo2_Blobo2
IOI next year isA :)
*/

//#pragma GCC optimize ("O3")
//#pragma GCC optimize ("unroll-loops")
#include<bits/stdc++.h>
#define int long long
#define endl "\n"
#define all(v)  v.begin(),v.end()
#define gen(arr,n,nxt)  generate(arr,arr+n,nxt)
#define base ios_base::sync_with_stdio(false);cin.tie(0);

using namespace std;
const int mo=1e9+7;
int nxt(){int x;cin>>x;return x;}

signed main(){
    base
    int n=nxt(),a=nxt(),b=nxt();
    a/=__gcd(a,b+1);
    int x=1000000000000000001;
    vector<pair<int,int> >v;
    if(a<=LLONG_MAX/b)
        x=a*b;
    bool flag=0;
    for(int i=0;i<n;i++){
        int first=nxt(),sec=nxt();
        if(sec-first+1>=x)flag=1;
        else if(sec%x<first%x){
            first%=x;
            sec%=x;
            v.push_back({first,x-1});
            v.push_back({0,sec});
        }
        else v.push_back({first%x,sec%x});
    }
    if(flag){
        cout<<x<<endl;
        return 0;
    }
    sort(all(v));
    int cnt=0,l=v[0].first,r=v[0].second;
    for(int i=0;i<v.size();i++){
        if(v[i].first<=r)r=max(r,v[i].second);
        else{
            cnt+=r-l+1;
            r=v[i].second;
            l=v[i].first;
        }
    }
    cnt+=r-l+1;
    cout<<cnt<<endl;
    return 0;
}

Compilation message

strange_device.cpp: In function 'int main()':
strange_device.cpp:46:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |     for(int i=0;i<v.size();i++){
      |                 ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 6 ms 976 KB Output is correct
3 Correct 6 ms 1056 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 312 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 312 KB Output is correct
14 Correct 1 ms 308 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 6 ms 1044 KB Output is correct
17 Correct 52 ms 3436 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 1 ms 312 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 252 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 354 ms 17800 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 502 ms 19916 KB Output is correct
3 Correct 469 ms 19096 KB Output is correct
4 Correct 463 ms 19096 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 502 ms 19916 KB Output is correct
3 Correct 469 ms 19096 KB Output is correct
4 Correct 463 ms 19096 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 482 ms 19084 KB Output is correct
7 Correct 508 ms 19016 KB Output is correct
8 Correct 481 ms 19092 KB Output is correct
9 Correct 502 ms 19044 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 502 ms 19916 KB Output is correct
3 Correct 469 ms 19096 KB Output is correct
4 Correct 463 ms 19096 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 48 ms 3540 KB Output is correct
7 Correct 49 ms 3620 KB Output is correct
8 Correct 48 ms 3556 KB Output is correct
9 Correct 54 ms 3664 KB Output is correct
10 Correct 47 ms 3608 KB Output is correct
11 Correct 48 ms 3536 KB Output is correct
12 Correct 46 ms 3648 KB Output is correct
13 Correct 49 ms 3648 KB Output is correct
14 Correct 47 ms 3672 KB Output is correct
15 Correct 52 ms 3648 KB Output is correct
16 Correct 53 ms 3576 KB Output is correct
17 Correct 49 ms 3476 KB Output is correct
18 Correct 481 ms 19060 KB Output is correct
19 Correct 472 ms 19176 KB Output is correct
20 Correct 523 ms 18984 KB Output is correct
21 Correct 54 ms 3648 KB Output is correct
22 Correct 45 ms 3596 KB Output is correct
23 Correct 146 ms 10784 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 55 ms 4412 KB Output is correct
3 Correct 51 ms 4272 KB Output is correct
4 Correct 554 ms 19940 KB Output is correct
5 Correct 52 ms 4032 KB Output is correct
6 Correct 52 ms 4236 KB Output is correct
7 Correct 50 ms 4052 KB Output is correct
8 Correct 52 ms 4048 KB Output is correct
9 Correct 50 ms 4028 KB Output is correct
10 Correct 54 ms 4100 KB Output is correct
11 Correct 63 ms 4028 KB Output is correct
12 Correct 45 ms 3952 KB Output is correct
13 Correct 53 ms 3984 KB Output is correct
14 Correct 550 ms 19912 KB Output is correct
15 Correct 51 ms 4028 KB Output is correct
16 Correct 471 ms 19944 KB Output is correct
17 Correct 465 ms 19904 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 6 ms 976 KB Output is correct
3 Correct 6 ms 1056 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 312 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 312 KB Output is correct
14 Correct 1 ms 308 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 6 ms 1044 KB Output is correct
17 Correct 52 ms 3436 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 312 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 1 ms 252 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 1 ms 328 KB Output is correct
26 Correct 1 ms 332 KB Output is correct
27 Correct 1 ms 332 KB Output is correct
28 Correct 354 ms 17800 KB Output is correct
29 Correct 1 ms 204 KB Output is correct
30 Correct 502 ms 19916 KB Output is correct
31 Correct 469 ms 19096 KB Output is correct
32 Correct 463 ms 19096 KB Output is correct
33 Correct 1 ms 204 KB Output is correct
34 Correct 482 ms 19084 KB Output is correct
35 Correct 508 ms 19016 KB Output is correct
36 Correct 481 ms 19092 KB Output is correct
37 Correct 502 ms 19044 KB Output is correct
38 Correct 1 ms 204 KB Output is correct
39 Correct 48 ms 3540 KB Output is correct
40 Correct 49 ms 3620 KB Output is correct
41 Correct 48 ms 3556 KB Output is correct
42 Correct 54 ms 3664 KB Output is correct
43 Correct 47 ms 3608 KB Output is correct
44 Correct 48 ms 3536 KB Output is correct
45 Correct 46 ms 3648 KB Output is correct
46 Correct 49 ms 3648 KB Output is correct
47 Correct 47 ms 3672 KB Output is correct
48 Correct 52 ms 3648 KB Output is correct
49 Correct 53 ms 3576 KB Output is correct
50 Correct 49 ms 3476 KB Output is correct
51 Correct 481 ms 19060 KB Output is correct
52 Correct 472 ms 19176 KB Output is correct
53 Correct 523 ms 18984 KB Output is correct
54 Correct 54 ms 3648 KB Output is correct
55 Correct 45 ms 3596 KB Output is correct
56 Correct 146 ms 10784 KB Output is correct
57 Correct 1 ms 204 KB Output is correct
58 Correct 55 ms 4412 KB Output is correct
59 Correct 51 ms 4272 KB Output is correct
60 Correct 554 ms 19940 KB Output is correct
61 Correct 52 ms 4032 KB Output is correct
62 Correct 52 ms 4236 KB Output is correct
63 Correct 50 ms 4052 KB Output is correct
64 Correct 52 ms 4048 KB Output is correct
65 Correct 50 ms 4028 KB Output is correct
66 Correct 54 ms 4100 KB Output is correct
67 Correct 63 ms 4028 KB Output is correct
68 Correct 45 ms 3952 KB Output is correct
69 Correct 53 ms 3984 KB Output is correct
70 Correct 550 ms 19912 KB Output is correct
71 Correct 51 ms 4028 KB Output is correct
72 Correct 471 ms 19944 KB Output is correct
73 Correct 465 ms 19904 KB Output is correct
74 Correct 1 ms 204 KB Output is correct
75 Correct 1 ms 320 KB Output is correct
76 Correct 1 ms 204 KB Output is correct
77 Correct 1 ms 204 KB Output is correct
78 Correct 1 ms 204 KB Output is correct
79 Correct 5 ms 976 KB Output is correct
80 Correct 558 ms 28196 KB Output is correct
81 Correct 591 ms 28196 KB Output is correct
82 Correct 532 ms 28248 KB Output is correct
83 Correct 508 ms 28196 KB Output is correct
84 Correct 575 ms 28200 KB Output is correct
85 Correct 511 ms 28244 KB Output is correct
86 Correct 155 ms 17456 KB Output is correct
87 Correct 1 ms 204 KB Output is correct