# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
345495 | 2021-01-07T13:32:52 Z | Kerim | 이상한 기계 (APIO19_strange_device) | C++17 | 562 ms | 53384 KB |
#include "bits/stdc++.h" #define MAXN 100009 #define INF 1000000007 #define mp(x,y) make_pair(x,y) #define all(v) v.begin(),v.end() #define pb(x) push_back(x) #define wr cout<<"----------------"<<endl; #define ppb() pop_back() #define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++) #define ff first #define ss second #define my_little_dodge 46 #define debug(x) cerr<< #x <<" = "<< x<<endl; using namespace std; typedef long long ll; typedef pair<ll,ll> PII; template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;} template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;} const ll B=1e18+1; int main(){ // freopen("file.in","r",stdin); int n; scanf("%d",&n); ll a,b; scanf("%lld%lld",&a,&b); ll mod=a/__gcd(a,b+1); if(a<=B/b) a*=b; else a=B; vector<PII>v; for(int i=1;i<=n;i++){ ll l,r; scanf("%lld%lld",&l,&r); if(r-l+1>=mod){ printf("%lld\n",mod); return 0; } l%=mod;r%=mod; if(l<=r) v.pb(mp(l,r)); else{ v.pb(mp(l,mod-1)); v.pb(mp(0,r)); } } sort(all(v)); PII as=mp(-1,-1); ll ans=0; tr(it,v){ if(as.ss<it->ff){ if(~as.ff) ans+=as.ss-as.ff+1; as=*it; } else umax(as.ss,it->ss); } printf("%lld\n",ans+as.ss-as.ff+1); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Incorrect | 6 ms | 1132 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Incorrect | 1 ms | 364 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Incorrect | 1 ms | 364 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 523 ms | 53384 KB | Output is correct |
3 | Correct | 513 ms | 26440 KB | Output is correct |
4 | Correct | 491 ms | 26440 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 523 ms | 53384 KB | Output is correct |
3 | Correct | 513 ms | 26440 KB | Output is correct |
4 | Correct | 491 ms | 26440 KB | Output is correct |
5 | Correct | 1 ms | 364 KB | Output is correct |
6 | Incorrect | 562 ms | 26568 KB | Output isn't correct |
7 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 523 ms | 53384 KB | Output is correct |
3 | Correct | 513 ms | 26440 KB | Output is correct |
4 | Correct | 491 ms | 26440 KB | Output is correct |
5 | Correct | 1 ms | 364 KB | Output is correct |
6 | Incorrect | 53 ms | 5724 KB | Output isn't correct |
7 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Incorrect | 1 ms | 364 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Incorrect | 6 ms | 1132 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |