Submission #1091877

#TimeUsernameProblemLanguageResultExecution timeMemory
1091877mispertionStrange Device (APIO19_strange_device)C++17
35 / 100
571 ms99928 KiB
#include<bits/stdc++.h> using namespace std; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); typedef long long ll; #define int ll typedef unsigned long long ull; typedef long double ld; typedef pair<int, int> pii; typedef pair<ll, ll> pll; #define pb push_back #define all(x) x.begin(), x.end() #define sz(x) (int)x.size() #define mispertion ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0) #define F first #define S second #define getlast(s) (*s.rbegin()) #define debg cout << "OK\n" const ld PI = 3.1415926535; const int N = 1e6 + 1; const int M = 50 + 1; const int mod = 1e9+7; const int infi = INT_MAX; const ll infl = LLONG_MAX; const int P = 31; int mult(int a, int b) { return a * 1LL * b % mod; } int sum(int a, int b) { if (a + b < 0) return a + b + mod; if (a + b >= mod) return a + b - mod; return a + b; } ll binpow(ll a, ll n) { if (n == 0) return 1; if (n % 2 == 1) { return binpow(a, n - 1) * a % mod; } else { ll b = binpow(a, n / 2); return b * b % mod; } } int n, A, B; map<int, int> mp; void solve(){ cin >> n >> A >> B; int ccl = A / gcd(A, B + 1) * B; for(int i = 1; i <= n; i++){ int l, r; cin >> l >> r; if(r - l + 1 >= ccl){ mp[0]++; mp[ccl]--; }else{ if(l % ccl <= r % ccl){ mp[l % ccl]++; mp[r % ccl + 1]--; }else{ mp[l % ccl]++; mp[ccl]--; mp[0]++; mp[r % ccl + 1]--; } } } int cur = 0, ans = 0; for(auto it = mp.begin(); it != (--mp.end()); it++){ auto it1 = it; it1++; cur += it->S; if(cur != 0) ans += (it1->F - it->F); } cout << ans << '\n'; } signed main() { mispertion; int t = 1; //cin >> t; while(t--){ solve(); } 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...