Submission #561302

#TimeUsernameProblemLanguageResultExecution timeMemory
561302baokhue232005Strange Device (APIO19_strange_device)C++14
65 / 100
442 ms18176 KiB
/* #pragma GCC optimize("Ofast") #pragma GCC target("avx,avx2,fma") #pragma GCC optimize("unroll-loops") */ // lethal option #include<bits/stdc++.h> using namespace std; #define all(flg) flg.begin(), flg.end() #define int long long #define pb push_back #define fi first #define se second #define endl "\n" #define eb emplace_back #define ii pair<int, int> #define PI 3.141592653589793238462643383279502884 #define ll long long #define for1(i, ff, gg) for(int i = ff; i <= gg; ++i) #define for2(i, ff, gg) for(int i = ff; i >= gg; --i) const ll mod = 1e9 + 7; const int maxN = 1000005; const ll oo = 2e18 + 7; int n, a[maxN]; int x, y, z, k; ii pr[maxN]; signed main(){ ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); cin >> n >> x >> y; x = (x / __gcd(x, y + 1)); z = y * x; if(z % x) z = oo; if(z % y) z = oo; set<ii> st; for1(i, 1, n){ cin >> x >> y; pr[i].fi = x % z; pr[i].se = y % z; } for1(i, 1, n){ if(pr[i].fi > pr[i].se){ ++n; pr[n].se = pr[i].se; pr[n].fi = 0; pr[i].se = z - 1; } } int lmx = -oo; sort(pr + 1, pr + n + 1); int ans = 0; for1(i, 1, n){ lmx = max(lmx, pr[i].fi - 1); ans += max(0ll, pr[i].se - lmx); lmx = max(lmx, pr[i].se); } cout << ans << endl; }
#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...