# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
659132 | 2022-11-16T17:12:55 Z | activedeltorre | Strange Device (APIO19_strange_device) | C++14 | 1603 ms | 178304 KB |
#include <iostream> #include <algorithm> #include <vector> #include <map> using namespace std; map<long long,long long>norm; vector<pair<long long,long long> >vec[2000005]; bool cmp(pair<long long,long long> a,pair<long long,long long>b) { if(a.first!=b.first) { return a.first<b.first; } return a.second>b.second; } int main() { long long n,i,j,m,k,l,a,b,val1,val2,rest1,rest2,valoare,cnt=0,x,y; cin>>n>>a>>b; for(i=1;i<=n;i++) { cin>>x>>y; val1=x/b; val2=y/b; rest1=x%b; rest2=y%b; if(val1==val2) { valoare=(val1*(b+1))%a; if(norm[valoare]==0) { cnt++; norm[valoare]=cnt; } vec[norm[valoare]].push_back({rest1,rest2}); } else { valoare=(val1*(b+1))%a; if(norm[valoare]==0) { cnt++; norm[valoare]=cnt; } vec[norm[valoare]].push_back({rest1,b-1}); valoare=(val2*(b+1))%a; if(norm[valoare]==0) { cnt++; norm[valoare]=cnt; } vec[norm[valoare]].push_back({0,rest2}); } } long long suma=0,nr,dr,index; for(i=1;i<=cnt;i++) { sort(vec[i].begin(),vec[i].end(),cmp); nr=vec[i].size(); if(nr>=1) { dr=-1; for(j=0;j<nr;j++) { index=j; dr=vec[i][j].second; while(index+1<nr && dr>=vec[i][index+1].first) { dr=max(dr,vec[i][index].second); index++; } suma=suma+dr-vec[i][j].first+1; j=index; } } } cout<<suma; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 22 ms | 47144 KB | Output is correct |
2 | Incorrect | 35 ms | 47940 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 26 ms | 47200 KB | Output is correct |
2 | Correct | 23 ms | 47224 KB | Output is correct |
3 | Correct | 24 ms | 47260 KB | Output is correct |
4 | Incorrect | 26 ms | 47188 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 23 ms | 47188 KB | Output is correct |
2 | Incorrect | 29 ms | 47396 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 24 ms | 47264 KB | Output is correct |
2 | Incorrect | 1603 ms | 178304 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 24 ms | 47264 KB | Output is correct |
2 | Incorrect | 1603 ms | 178304 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 24 ms | 47264 KB | Output is correct |
2 | Incorrect | 1603 ms | 178304 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 22 ms | 47264 KB | Output is correct |
2 | Incorrect | 154 ms | 52888 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 22 ms | 47144 KB | Output is correct |
2 | Incorrect | 35 ms | 47940 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |