# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
977109 | 2024-05-07T11:48:08 Z | Batorgil952 | Strange Device (APIO19_strange_device) | C++14 | 367 ms | 17584 KB |
#include<bits/stdc++.h> #define ll long long #define pb push_back #define mp make_pair #define ff first #define ss second using namespace std; ll GCD(ll x, ll y){ while(x*y!=0){ if(x>y) x%=y; else y%=x; } return x+y; } int main(){ ll n, i, A, B, l, r, k, m, ma, ans; vector< pair< ll, ll > > v; scanf("%lld",&n); scanf("%lld",&A); scanf("%lld",&B); m=GCD(B+1, A); A/=m; ma=1000000000000000002; if(ma/A<B){ k=ma; } else{ k=A*B; } // cout<<k<<endl; ans=0; for(i=1; i<=n; i++){ scanf("%lld",&l); scanf("%lld",&r); if(r-l+1>=k){ ans=k; } if(l%k<=r%k) v.pb(mp(l%k, r%k)); else{ v.pb(mp(l%k, k-1)); v.pb(mp(0, r%k)); } } if(ans==k){ printf("%lld\n", k); return 0; } sort(v.begin(), v.end()); l=v[0].ff; r=v[0].ss; for(i=1; i<n; i++){ if(v[i].ff<=r){ r=max(r, v[i].ss); } else{ ans+=(r-l+1); l=v[i].ff; r=v[i].ss; } } ans+=(r-l+1); printf("%lld\n", ans); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 3 ms | 724 KB | Output is correct |
3 | Incorrect | 4 ms | 724 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 500 KB | Output is correct |
2 | Incorrect | 1 ms | 344 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 361 ms | 17584 KB | Output is correct |
3 | Incorrect | 308 ms | 17064 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 361 ms | 17584 KB | Output is correct |
3 | Incorrect | 308 ms | 17064 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 361 ms | 17584 KB | Output is correct |
3 | Incorrect | 308 ms | 17064 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 34 ms | 2548 KB | Output is correct |
3 | Correct | 33 ms | 2512 KB | Output is correct |
4 | Correct | 367 ms | 17276 KB | Output is correct |
5 | Correct | 41 ms | 2512 KB | Output is correct |
6 | Correct | 33 ms | 2508 KB | Output is correct |
7 | Correct | 36 ms | 2508 KB | Output is correct |
8 | Correct | 33 ms | 2512 KB | Output is correct |
9 | Correct | 33 ms | 2512 KB | Output is correct |
10 | Correct | 33 ms | 2512 KB | Output is correct |
11 | Correct | 36 ms | 2512 KB | Output is correct |
12 | Incorrect | 32 ms | 2512 KB | Output isn't correct |
13 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 3 ms | 724 KB | Output is correct |
3 | Incorrect | 4 ms | 724 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |