Submission #721458

# Submission time Handle Problem Language Result Execution time Memory
721458 2023-04-11T01:53:28 Z Darren0724 Strange Device (APIO19_strange_device) C++17
5 / 100
453 ms 17068 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) x.begin(),x.end()
const int INF=9e18;

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t;cin>>t;
    int a,b;cin>>a>>b;
    int m=0;
    if(INF/a<b){
        m=INF;
    }
    else{
        m=a*b;
    }
    vector<pair<int,int>> v;
    for(int i=0;i<t;i++){
        int l,r;cin>>l>>r;
        /*if(r-l+1>=m){
            cout<<m<<endl;
            return 0;
        }*/
        if(r%m<l%m){
            v.push_back({l%m,m-1});
            v.push_back({0,r%m});
        }
        else{
            v.push_back({l%m,r%m});
        }
    }
    sort(all(v));
    int ans=0;
    int l=0;
    for(pair<int,int> p:v){
        p.first=max(p.first,l);
        if(p.second<p.first){
            continue;
        }
        ans+=(p.second-p.first+1);
        l=p.second+1;
    }
    cout<<ans<<endl;


    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 5 ms 616 KB Output is correct
3 Correct 5 ms 600 KB Output is correct
4 Incorrect 0 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory 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 297 ms 16788 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 400 ms 16876 KB Output is correct
3 Incorrect 400 ms 17068 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 400 ms 16876 KB Output is correct
3 Incorrect 400 ms 17068 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 400 ms 16876 KB Output is correct
3 Incorrect 400 ms 17068 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 42 ms 2524 KB Output is correct
3 Correct 51 ms 2508 KB Output is correct
4 Correct 453 ms 16748 KB Output is correct
5 Correct 41 ms 2500 KB Output is correct
6 Correct 40 ms 2464 KB Output is correct
7 Correct 42 ms 2524 KB Output is correct
8 Correct 45 ms 2460 KB Output is correct
9 Correct 42 ms 2492 KB Output is correct
10 Correct 54 ms 2500 KB Output is correct
11 Correct 41 ms 2512 KB Output is correct
12 Correct 36 ms 2432 KB Output is correct
13 Correct 39 ms 2460 KB Output is correct
14 Correct 445 ms 16816 KB Output is correct
15 Incorrect 42 ms 2512 KB Output isn't correct
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 5 ms 616 KB Output is correct
3 Correct 5 ms 600 KB Output is correct
4 Incorrect 0 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -