# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
910915 | 2024-01-18T09:27:05 Z | green_gold_dog | Strange Device (APIO19_strange_device) | C++17 | 808 ms | 81848 KB |
//#pragma GCC optimize("Ofast") //#pragma GCC target("avx,avx2,sse,sse2,sse3,ssse3,sse4,abm,popcnt,mmx") #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef double db; typedef long double ldb; typedef complex<double> cd; constexpr ll INF64 = 1'000'000'000'000'000'000, INF32 = 2'000'000'000, MOD = 1'000'000'007; constexpr db PI = acos(-1); constexpr bool IS_FILE = false, IS_TEST_CASES = false; random_device rd; mt19937 rnd32(rd()); mt19937_64 rnd64(rd()); template<typename T> bool assign_max(T& a, T b) { if (b > a) { a = b; return true; } return false; } template<typename T> bool assign_min(T& a, T b) { if (b < a) { a = b; return true; } return false; } template<typename T> T square(T a) { return a * a; } template<> struct std::hash<pair<ll, ll>> { ll operator() (pair<ll, ll> p) const { return ((__int128)p.first * MOD + p.second) % INF64; } }; void solve() { ll n, a, b; cin >> n >> a >> b; ll mod = a * b; if (mod / a >= b) { mod = a * b; } map<ll, ll> add; for (ll i = 0; i < n; i++) { ll l, r; cin >> l >> r; r++; if (r - l >= mod) { cout << mod << '\n'; return; } l %= mod; r %= mod; if (l <= r) { add[l]++; add[r]--; } else { add[0]++; add[mod]--; add[l]++; add[r]--; } } ll now = 0; ll ans = 0; ll lst = 0; for (auto[a, b] : add) { if (now) { ans += a - lst; } lst = a; now += b; } cout << ans << '\n'; } int main() { if (IS_FILE) { freopen("", "r", stdin); freopen("", "w", stdout); } ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); ll t = 1; if (IS_TEST_CASES) { cin >> t; } for (ll i = 0; i < t; i++) { solve(); } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 5 ms | 1372 KB | Output is correct |
3 | Correct | 5 ms | 1372 KB | Output is correct |
4 | Incorrect | 1 ms | 348 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 1 ms | 344 KB | Output is correct |
4 | Correct | 1 ms | 344 KB | Output is correct |
5 | Incorrect | 0 ms | 412 KB | Output isn't correct |
6 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 600 KB | Output is correct |
2 | Correct | 1 ms | 344 KB | Output is correct |
3 | Correct | 1 ms | 344 KB | Output is correct |
4 | Correct | 1 ms | 348 KB | Output is correct |
5 | Correct | 179 ms | 13324 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 546 ms | 81756 KB | Output is correct |
3 | Incorrect | 644 ms | 81632 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 546 ms | 81756 KB | Output is correct |
3 | Incorrect | 644 ms | 81632 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 546 ms | 81756 KB | Output is correct |
3 | Incorrect | 644 ms | 81632 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 348 KB | Output is correct |
2 | Correct | 57 ms | 8564 KB | Output is correct |
3 | Correct | 50 ms | 8532 KB | Output is correct |
4 | Correct | 625 ms | 81848 KB | Output is correct |
5 | Correct | 52 ms | 8532 KB | Output is correct |
6 | Correct | 54 ms | 8596 KB | Output is correct |
7 | Correct | 52 ms | 8568 KB | Output is correct |
8 | Correct | 53 ms | 8532 KB | Output is correct |
9 | Correct | 52 ms | 8528 KB | Output is correct |
10 | Correct | 47 ms | 8532 KB | Output is correct |
11 | Correct | 47 ms | 8600 KB | Output is correct |
12 | Correct | 52 ms | 8624 KB | Output is correct |
13 | Correct | 55 ms | 8532 KB | Output is correct |
14 | Correct | 808 ms | 81776 KB | Output is correct |
15 | Incorrect | 54 ms | 8720 KB | Output isn't correct |
16 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 5 ms | 1372 KB | Output is correct |
3 | Correct | 5 ms | 1372 KB | Output is correct |
4 | Incorrect | 1 ms | 348 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |