제출 #569541

#제출 시각아이디문제언어결과실행 시간메모리
569541Trunkty이상한 기계 (APIO19_strange_device)C++14
0 / 100
1 ms212 KiB
#include <iostream> #include <vector> #include <algorithm> #include <map> using namespace std; typedef long long ll; #define DEBUG #ifdef DEBUG #define debug(x) cout << #x << ": " << x << endl #else #define debug(x) #endif ll inf = 2e18; ll n,a,b,p; map<ll,ll> mp; ll bef,curr,ans; int main(){ ios::sync_with_stdio(false); cin.tie(NULL); cin >> n >> a >> b; ll gc = __gcd(a,b+1LL); if(a/gc>inf/b){ p = 1e18; } else{ p = a/gc*b; } for(ll i=1;i<=n;i++){ ll c,d; cin >> c >> d; if(d-c+1LL>=p){ return 0; } else{ c %= p; d %= p; if(c<=d){ mp[c]++; mp[d+1LL]--; } else{ mp[0]++; mp[d+1LL]--; mp[c]++; mp[p]--; } } } for(auto it=mp.begin();it!=mp.end();it++){ if(curr){ ans += it->first-bef; } bef = it->first; curr += it->second; } cout << ans << "\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...