답안 #540595

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
540595 2022-03-21T06:15:37 Z krit3379 이상한 기계 (APIO19_strange_device) C++17
15 / 100
587 ms 53300 KB
#include<bits/stdc++.h>
using namespace std;
#define N 1000005

long long a,b,g,rb,l,r,ll,rr,flag,ans;
vector<pair<long long,long long>> p;

int main(){
    int n,i;
    scanf("%d %lld %lld",&n,&a,&b);
    g=__gcd(a,b+1);
    r=a/g;
    if(1e18/r>b)rb=r*b;
    else rb=1e18+1;
    for(i=1;i<=n;i++){
        scanf("%lld %lld",&l,&r);
        if(r-l+1>=rb)flag=true;
        l%=rb;
        r%=rb;
        if(l<=r)p.push_back({l,r});
        else p.push_back({l,rb-1}),p.push_back({0,r});
    }
    if(flag){printf("%lld",rb);return 0;}
    sort(p.begin(),p.end());
    ll=-1;
    rr=-2;
    for(auto [l,r]:p){
        if(l<=rr)rr=r;
        else{
            ans+=rr-ll+1;
            ll=l,rr=r;
        }
    }
    ans+=rr-ll+1;
    printf("%lld",ans);
    return 0;
}

Compilation message

strange_device.cpp: In function 'int main()':
strange_device.cpp:10:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |     scanf("%d %lld %lld",&n,&a,&b);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
strange_device.cpp:16:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |         scanf("%lld %lld",&l,&r);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 388 KB Output is correct
2 Incorrect 6 ms 1040 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 308 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 300 KB Output is correct
4 Correct 1 ms 304 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 Incorrect 1 ms 360 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 527 ms 53244 KB Output is correct
3 Correct 521 ms 53216 KB Output is correct
4 Correct 472 ms 53224 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 527 ms 53244 KB Output is correct
3 Correct 521 ms 53216 KB Output is correct
4 Correct 472 ms 53224 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 542 ms 53192 KB Output is correct
7 Correct 550 ms 53148 KB Output is correct
8 Correct 522 ms 53228 KB Output is correct
9 Correct 540 ms 53300 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 527 ms 53244 KB Output is correct
3 Correct 521 ms 53216 KB Output is correct
4 Correct 472 ms 53224 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 48 ms 5720 KB Output is correct
7 Correct 54 ms 5696 KB Output is correct
8 Correct 50 ms 5596 KB Output is correct
9 Correct 49 ms 5660 KB Output is correct
10 Correct 54 ms 5616 KB Output is correct
11 Correct 50 ms 5628 KB Output is correct
12 Correct 51 ms 5672 KB Output is correct
13 Correct 50 ms 5700 KB Output is correct
14 Correct 46 ms 5600 KB Output is correct
15 Incorrect 58 ms 5596 KB Output isn't correct
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 304 KB Output is correct
2 Correct 49 ms 5712 KB Output is correct
3 Correct 62 ms 5640 KB Output is correct
4 Correct 587 ms 53200 KB Output is correct
5 Correct 55 ms 5624 KB Output is correct
6 Correct 47 ms 5600 KB Output is correct
7 Correct 49 ms 5740 KB Output is correct
8 Correct 58 ms 5720 KB Output is correct
9 Correct 59 ms 5648 KB Output is correct
10 Correct 49 ms 5584 KB Output is correct
11 Correct 50 ms 5668 KB Output is correct
12 Correct 47 ms 5676 KB Output is correct
13 Correct 49 ms 5652 KB Output is correct
14 Incorrect 540 ms 53248 KB Output isn't correct
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 388 KB Output is correct
2 Incorrect 6 ms 1040 KB Output isn't correct
3 Halted 0 ms 0 KB -