답안 #744178

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
744178 2023-05-18T08:59:50 Z iamporrrrrrrrr 이상한 기계 (APIO19_strange_device) C++14
35 / 100
539 ms 17328 KB
#include <bits/stdc++.h>
#define int long long
using namespace std;
set<int> s;
vector<pair<int,int>> v;
int g(int a,int b){
    if(b==0) return a;
    return g(b,a%b);
}
signed main()
{
    ios::sync_with_stdio(0),cin.tie(0);
    int n,a,b;
    cin>>n>>a>>b;
    int mod = (a*b)/g(max(a,b+1),min(a,b+1));
    for(int i=1;i<=n;i++){
        int x,y;
        cin>>x>>y;
        if(y-x>=mod){
            cout<<mod;
            return 0;
        }
        x%=mod;
        y%=mod;
        if(y>=x){
            v.push_back({x,y});
        }
        else v.push_back({x,mod-1}),v.push_back({0,y});

    }
    sort(v.begin(),v.end());
    int rr=-1,ans=0;
    for(int i=0;i<v.size();i++){
        int l=v[i].first;
        int r=v[i].second;
        if(l>rr){
            ans+=(r-l+1);
            rr=r;
        }
        else if(l<=rr&&r>rr){
            ans+=(r-rr);
            rr=r;
        }
    }
    cout<<ans;
    return 0;
}

Compilation message

strange_device.cpp: In function 'int main()':
strange_device.cpp:33: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]
   33 |     for(int i=0;i<v.size();i++){
      |                 ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 5 ms 600 KB Output is correct
3 Correct 4 ms 600 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 4 ms 600 KB Output is correct
17 Correct 44 ms 2468 KB Output is correct
18 Incorrect 0 ms 212 KB Output isn't correct
19 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 316 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Incorrect 1 ms 212 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 284 ms 16820 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 389 ms 16904 KB Output is correct
3 Correct 392 ms 16876 KB Output is correct
4 Correct 358 ms 16856 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 389 ms 16904 KB Output is correct
3 Correct 392 ms 16876 KB Output is correct
4 Correct 358 ms 16856 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 384 ms 16856 KB Output is correct
7 Correct 412 ms 16764 KB Output is correct
8 Correct 400 ms 16840 KB Output is correct
9 Correct 441 ms 16812 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 389 ms 16904 KB Output is correct
3 Correct 392 ms 16876 KB Output is correct
4 Correct 358 ms 16856 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 50 ms 2776 KB Output is correct
7 Correct 46 ms 2792 KB Output is correct
8 Correct 46 ms 2764 KB Output is correct
9 Correct 48 ms 2760 KB Output is correct
10 Correct 41 ms 2756 KB Output is correct
11 Correct 47 ms 2824 KB Output is correct
12 Correct 39 ms 2744 KB Output is correct
13 Correct 53 ms 2796 KB Output is correct
14 Correct 50 ms 2776 KB Output is correct
15 Correct 54 ms 2688 KB Output is correct
16 Correct 50 ms 2740 KB Output is correct
17 Correct 58 ms 2712 KB Output is correct
18 Correct 464 ms 17124 KB Output is correct
19 Correct 460 ms 16980 KB Output is correct
20 Correct 523 ms 17284 KB Output is correct
21 Correct 52 ms 2764 KB Output is correct
22 Correct 49 ms 2764 KB Output is correct
23 Correct 148 ms 9152 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 57 ms 2728 KB Output is correct
3 Correct 54 ms 2756 KB Output is correct
4 Correct 539 ms 17292 KB Output is correct
5 Correct 49 ms 2928 KB Output is correct
6 Correct 52 ms 2744 KB Output is correct
7 Correct 51 ms 2764 KB Output is correct
8 Correct 52 ms 2736 KB Output is correct
9 Correct 49 ms 2768 KB Output is correct
10 Correct 53 ms 2688 KB Output is correct
11 Correct 58 ms 2692 KB Output is correct
12 Correct 47 ms 2748 KB Output is correct
13 Correct 46 ms 2720 KB Output is correct
14 Correct 496 ms 17328 KB Output is correct
15 Correct 54 ms 2660 KB Output is correct
16 Correct 465 ms 17300 KB Output is correct
17 Correct 411 ms 17296 KB Output is correct
18 Incorrect 1 ms 212 KB Output isn't correct
19 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 5 ms 600 KB Output is correct
3 Correct 4 ms 600 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 4 ms 600 KB Output is correct
17 Correct 44 ms 2468 KB Output is correct
18 Incorrect 0 ms 212 KB Output isn't correct
19 Halted 0 ms 0 KB -