Submission #729202

# Submission time Handle Problem Language Result Execution time Memory
729202 2023-04-23T15:50:19 Z 1075508020060209tc Strange Device (APIO19_strange_device) C++14
5 / 100
1480 ms 69660 KB
#include<bits/stdc++.h>

using namespace std;
#define int long long
int n;int A;int B;


int ar[1000006];int br[1000006];

signed main(){
cin>>n>>A>>B;
for(int i=1;i<=n;i++){
    cin>>ar[i]>>br[i];
}
if(A%2==0){
    A/=2;
}
vector<pair<int,int>>seg;
for(int i=1;i<=n;i++){
    if(br[i]-ar[i]+1>=A){
        cout<<A;return 0;
    }
    int l=ar[i]%A;int r=br[i]%A;
    if(r<l){
        seg.push_back({l,A-1});
        seg.push_back({0,r});
    }else{
        seg.push_back({l,r});
    }
}
sort(seg.begin(),seg.end());
int ans=0;
int rpl=seg[0].second;
int lpl=seg[0].first;
for(int i=1;i<seg.size();i++){

    if(seg[i].first<=rpl+1){
        rpl=max(rpl,seg[i].second);
        continue;
    }else{
        ans+=rpl-lpl+1;
        lpl=seg[i].first;rpl=seg[i].second;
    }
}
ans+=rpl-lpl+1;
cout<<ans<<endl;

}


Compilation message

strange_device.cpp: In function 'int main()':
strange_device.cpp:36:14: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 | for(int i=1;i<seg.size();i++){
      |             ~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 18 ms 808 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 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 2 ms 340 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 1366 ms 32512 KB Output is correct
3 Correct 1409 ms 69660 KB Output is correct
4 Correct 1390 ms 69540 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1366 ms 32512 KB Output is correct
3 Correct 1409 ms 69660 KB Output is correct
4 Correct 1390 ms 69540 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Incorrect 1480 ms 69504 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1366 ms 32512 KB Output is correct
3 Correct 1409 ms 69660 KB Output is correct
4 Correct 1390 ms 69540 KB Output is correct
5 Correct 1 ms 304 KB Output is correct
6 Incorrect 149 ms 7660 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 132 ms 5524 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 Incorrect 18 ms 808 KB Output isn't correct
3 Halted 0 ms 0 KB -