제출 #447185

#제출 시각아이디문제언어결과실행 시간메모리
447185Ya_Ali이상한 기계 (APIO19_strange_device)C++17
10 / 100
584 ms53212 KiB
/* ** *** In the name of God *** ** */ // Only Haider is Amir al-Momenin #include <bits/stdc++.h> using namespace std; typedef long long ll; const ll maxn = 1e5 + 10; const ll mod = 1e9 + 7; #define endl '\n' int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); ll n, A, B; cin >> n >> A >> B; ll x = 1ll * A / __gcd(A, B + 1); x = 1ll * x * B; vector<pair<ll, ll>> b; while (n--) { ll l, r; cin >> l >> r; l--, r--; if (r - l + 1 >= x) return cout << x, 0; l %= x, r %= x; if (r >= l) b.push_back({l, r}); else b.push_back({l, x - 1}), b.push_back({0, r}); } sort(b.begin(), b.end()); ll p = 0, ans = x; // cout << x << endl; for (auto i : b) { ll l = i.first, r = i.second; // cout << l << ' ' << r << endl; if (l > p) ans -= (l - p); p = r + 1; } ans -= (x - p); cout << ans; 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...