Submission #1031788

# Submission time Handle Problem Language Result Execution time Memory
1031788 2024-07-23T07:12:15 Z stdfloat Strange Device (APIO19_strange_device) C++17
0 / 100
433 ms 92772 KB
#include <bits/stdc++.h>
using namespace std;

using ll = long long;

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);

    int n;
    ll A, B;
    cin >> n >> A >> B;

    int L = (A & 1 ? A : A >> 1);
    map<int, int> m;
    while (n--) {
        ll l, r;
        cin >> l >> r;

        if (L <= r - l + 1) {
            m[0]++; m[L]--;
            continue;
        }

        m[l % L]++; m[r % L + 1]--;

        if (l % L > r % L) {
            m[0]++; m[L]--;
        }
    }

    vector<pair<int, int>> v;
    for (auto i : m) v.push_back(i);

    int sm = 0;
    ll ans = 0;
    for (int i = 0; i + 1 < (int)v.size(); i++) {
        sm += v[i].second;
        ans += !!sm * (v[i + 1].first - v[i].first);
    }

    cout << ans << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 3 ms 860 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 433 ms 92772 KB Output is correct
3 Incorrect 386 ms 92756 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 433 ms 92772 KB Output is correct
3 Incorrect 386 ms 92756 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 433 ms 92772 KB Output is correct
3 Incorrect 386 ms 92756 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 48 ms 4632 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 3 ms 860 KB Output isn't correct
3 Halted 0 ms 0 KB -