Submission #721452

# Submission time Handle Problem Language Result Execution time Memory
721452 2023-04-11T01:48:05 Z Darren0724 Strange Device (APIO19_strange_device) C++17
10 / 100
1354 ms 53344 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) x.begin(),x.end()
const int INF=1e18;

int32_t main(){
    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 13 ms 676 KB Output is correct
3 Correct 14 ms 1060 KB Output is correct
4 Incorrect 1 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 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 2 ms 212 KB Output is correct
3 Correct 2 ms 352 KB Output is correct
4 Correct 2 ms 340 KB Output is correct
5 Correct 926 ms 41288 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1260 ms 16824 KB Output is correct
3 Incorrect 1302 ms 45240 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1260 ms 16824 KB Output is correct
3 Incorrect 1302 ms 45240 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1260 ms 16824 KB Output is correct
3 Incorrect 1302 ms 45240 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 141 ms 2352 KB Output is correct
3 Correct 134 ms 5668 KB Output is correct
4 Correct 1354 ms 53300 KB Output is correct
5 Correct 135 ms 5732 KB Output is correct
6 Correct 134 ms 5700 KB Output is correct
7 Correct 133 ms 5584 KB Output is correct
8 Correct 137 ms 5676 KB Output is correct
9 Correct 134 ms 5692 KB Output is correct
10 Correct 131 ms 5672 KB Output is correct
11 Correct 135 ms 5668 KB Output is correct
12 Correct 128 ms 5668 KB Output is correct
13 Correct 129 ms 5700 KB Output is correct
14 Correct 1336 ms 53344 KB Output is correct
15 Incorrect 132 ms 5624 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 13 ms 676 KB Output is correct
3 Correct 14 ms 1060 KB Output is correct
4 Incorrect 1 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -