# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
659129 | 2022-11-16T17:03:06 Z | activedeltorre | Strange Device (APIO19_strange_device) | C++14 | 66 ms | 95644 KB |
#include <iostream> #include <algorithm> #include <vector> #include <map> using namespace std; map<long long ,int>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(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 | Runtime error | 57 ms | 95564 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 66 ms | 95572 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 59 ms | 95644 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 58 ms | 95636 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 58 ms | 95636 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 58 ms | 95636 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 61 ms | 95540 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 57 ms | 95564 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |