Submission #1044592

# Submission time Handle Problem Language Result Execution time Memory
1044592 2024-08-05T11:26:08 Z vjudge1 Strange Device (APIO19_strange_device) C++17
0 / 100
224 ms 53308 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;
        cntofdif*=b;
        cntofdif=min<lint>(cntofdif,mod*mod);
    }
    int all=cntofdif;
    //cerr<<all<<"\n";
    vector<pii>ranges;
    for(int i=0;i<n;i++){
        int l,r;
        cin>>l>>r;
        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;
        }
        //cerr<<f<<" "<<s<<" "<<cnt<<"\n";
        left=max(left,s);
    }
    cout<<cnt<<"\n";
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 3 ms 1116 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 1 ms 604 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 224 ms 53308 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 224 ms 53308 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 224 ms 53308 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 24 ms 5676 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 3 ms 1116 KB Output isn't correct
3 Halted 0 ms 0 KB -