# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
649774 | 2022-10-11T10:47:59 Z | ToroTN | Strange Device (APIO19_strange_device) | C++14 | 1 ms | 300 KB |
#include<bits/stdc++.h> using namespace std; #define ll long long #define X first #define Y second #define pb push_back ll n,a,b,x,y,md,cnt=0,mx=-1,l,r,di; set<pair<ll,ll> > s; vector<pair<ll,ll> > v; int main() { scanf("%lld%lld%lld",&n,&a,&b); di=a/__gcd(b+1,a); if(di>(1e18+1)/b) { md=1e18+1; }else { md=di*b; } printf("%lld\n",md); for(int i=1;i<=n;i++) { scanf("%lld%lld",&x,&y); x%=md; y%=md; if(x<=y) { v.pb({x,y}); }else { v.pb({x,md-1}); v.pb({0,y}); } } sort(v.begin(),v.end()); for(int i=0;i<v.size();i++) { l=v[i].X; r=v[i].Y; if(l>mx) { cnt+=(r-l+1); mx=r; }else { if(r>mx) { cnt+=r-mx; mx=r; } } } printf("%lld\n",cnt); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 212 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 212 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 212 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 300 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 300 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 300 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 212 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 212 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |