답안 #1044617

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1044617 2024-08-05T11:44:09 Z vjudge1 이상한 기계 (APIO19_strange_device) C++17
5 / 100
233 ms 18624 KB
#include "bits/stdc++.h"
using namespace std;

#define int int64_t    
#define pb push_back

using lint=__int128_t;

const int lim=200100;
const int mod=1e9+7;

using pii=pair<int,int>;

signed main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#ifdef Local  
    freopen(".in","r",stdin);freopen(".out","w",stdout);
#endif
    int n,a,b;
    cin>>n>>a>>b;
    lint cntofdif;
    if((b+1)%a==0){
        cntofdif=b;
    }else{
        cntofdif=a/__gcd(a,(b+1));
        cntofdif*=b;
        cntofdif=min<lint>(cntofdif,int(2e18));
    }
    int all=cntofdif;
    vector<pii>ranges;
    for(int i=0;i<n;i++){
        int l,r;
        cin>>l>>r;
        if(all<=r-l+1){
            cout<<all;
            return 0;
        }
        l%=all;
        r%=all;
        if(l<=r){
            ranges.pb({l,r});
            //cerr<<"inserted "<<l<<" "<<r<<"\n";
        }
        else{
            //cerr<<"oops "<<l<<" "<<r<<"\n";
            ranges.pb({l,all-1});
            ranges.pb({0,r});
        }
    }
    sort(ranges.begin(),ranges.end());
    int cnt=0,left=-1;
    for(auto[f,s]:ranges){
        if(left<f){
            cnt+=s-f+1;
        }else{
            cnt+=s-left;
        }
        left=max(left,s);
    }
    cout<<cnt<<"\n";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 2 ms 736 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 233 ms 18624 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 233 ms 18624 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 233 ms 18624 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 28 ms 2564 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 2 ms 736 KB Output isn't correct
3 Halted 0 ms 0 KB -