Submission #975039

# Submission time Handle Problem Language Result Execution time Memory
975039 2024-05-04T10:30:05 Z hirayuu_oj Strange Device (APIO19_strange_device) C++17
10 / 100
356 ms 54036 KB
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define all(x) x.begin(),x.end()
using ll=long long;
const ll INF=1LL<<61;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n,A,B;
    cin>>n>>A>>B;
    ll rp=A*B;
    if((INF/A)/B==0LL){
        rp=INF;
    }
    vector<pair<ll,ll>> segs;
    rep(i,n){
        ll l,r;
        cin>>l>>r;
        r++;
        if(r-l>=rp){
            cout<<rp<<"\n";
            return 0;
        }
        l%=rp;
        r%=rp;
        if(l<r){
            segs.emplace_back(pair<ll,ll>(l,r));
        }
        if(l>r){
            segs.emplace_back(pair<ll,ll>(l,rp));
            segs.emplace_back(pair<ll,ll>(0,r));
        }
    }
    sort(all(segs));
    ll lf=0,ri=0;
    ll ans=0;
    for(auto &[nl,nr]:segs){
        if(nl<ri){
            ri=max(ri,nr);
        }
        else{
            ans+=ri-lf;
            lf=nl;
            ri=nr;
        }
    }
    ans+=ri-lf;
    cout<<ans<<"\n";
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 3 ms 1116 KB Output is correct
3 Correct 4 ms 1108 KB Output is correct
4 Incorrect 0 ms 388 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 460 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 209 ms 41296 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 308 ms 53180 KB Output is correct
3 Incorrect 322 ms 53144 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 308 ms 53180 KB Output is correct
3 Incorrect 322 ms 53144 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 308 ms 53180 KB Output is correct
3 Incorrect 322 ms 53144 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 34 ms 5844 KB Output is correct
3 Correct 37 ms 5788 KB Output is correct
4 Correct 356 ms 54036 KB Output is correct
5 Correct 35 ms 5832 KB Output is correct
6 Correct 34 ms 5776 KB Output is correct
7 Correct 33 ms 5840 KB Output is correct
8 Correct 36 ms 5836 KB Output is correct
9 Correct 33 ms 5844 KB Output is correct
10 Correct 33 ms 5836 KB Output is correct
11 Correct 33 ms 5832 KB Output is correct
12 Correct 29 ms 5848 KB Output is correct
13 Correct 34 ms 5684 KB Output is correct
14 Correct 345 ms 53160 KB Output is correct
15 Incorrect 43 ms 5832 KB Output isn't correct
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 3 ms 1116 KB Output is correct
3 Correct 4 ms 1108 KB Output is correct
4 Incorrect 0 ms 388 KB Output isn't correct
5 Halted 0 ms 0 KB -