Submission #1010166

# Submission time Handle Problem Language Result Execution time Memory
1010166 2024-06-28T12:17:59 Z RandomUser Strange Device (APIO19_strange_device) C++17
0 / 100
975 ms 63036 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

const int mod = 1e9 + 7;

int main() {
    ll n, A, B;
    cin >> n >> A >> B;

    ll P = A / __gcd(A, B + 1) * B;

    set<pair<ll, ll> > st;
    for(int i=0; i<n; i++) {
        ll L, R;
        cin >> L >> R;
        
        if(P <= 0) {
            st.insert({ L, R });
            continue;
        }

        ll a = L % P, b = R % P;
        if(L == R) {
            st.insert({ a, b });
        } else if(a < b) {
            st.insert({ a, b });
        } else {
            st.insert({ a, P - 1 });
            st.insert({ 0, b });
        }
    }

    ll res = 0, right_point = -1;
    for(auto &it : st) {
        // cout << it.first << " " << it.second << '\n';
        if(it.second <= right_point) continue;
        if(it.first > right_point) {
            res += it.second - it.first + 1;
            right_point = it.second;
        } else {
            res += it.second - right_point;
        }
    }

    cout << res << '\n';
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Incorrect 9 ms 920 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 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 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 Incorrect 975 ms 63036 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 975 ms 63036 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 975 ms 63036 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 96 ms 6448 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Incorrect 9 ms 920 KB Output isn't correct
3 Halted 0 ms 0 KB -