Submission #568637

#TimeUsernameProblemLanguageResultExecution timeMemory
568637four_specksStrange Device (APIO19_strange_device)C++17
35 / 100
504 ms58020 KiB
#include <bits/stdc++.h> using namespace std; inline namespace { } // namespace void solve() { int n; long a, b; cin >> n >> a >> b; vector<array<long, 2>> v(n); for (auto &[x, y] : v) cin >> x >> y, ++y; long c = a * b / gcd(a, b + 1); vector<array<long, 2>> u; for (auto [x, y] : v) { if (y - x >= c) u.push_back({0, c}); else { x %= c, y %= c; if (x < y) u.push_back({x, y}); else u.push_back({x, c}), u.push_back({0, y}); } } sort(u.begin(), u.end()); long cnt = 0; long d = 0; for (auto [x, y] : u) { if (y > d) { cnt += y - max(x, d); d = y; } } cout << cnt << '\n'; } int main() { ios_base::sync_with_stdio(false), cin.tie(NULL); 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...