Submission #636017

# Submission time Handle Problem Language Result Execution time Memory
636017 2022-08-27T16:35:03 Z ljuba Strange Device (APIO19_strange_device) C++17
5 / 100
5000 ms 524288 KB
#include <bits/stdc++.h>

using namespace std;

using ll = long long;

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

    int n;
    ll a, b;
    cin >> n >> a >> b;

    vector<pair<ll, ll>> v(n);

    for(auto &z : v) cin >> z.first >> z.second;

    if(n == 1) {
        ll ima = v[0].second - v[0].first + 1;

        //a * b > ima
        if(a > (ima + b - 1) / b) {
            cout << ima << '\n';
        } else {
            cout << min(a * b, ima) << '\n';
        }

        return 0;
    }

    set<pair<int, int>> s;

    for(auto z : v) {
        for(int i = z.first; i <= z.second; ++i) {
            s.insert({i % a, i % b});
        }
    }

    cout << int(s.size()) << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Execution timed out 5058 ms 76352 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Execution timed out 5090 ms 15356 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Execution timed out 5097 ms 73824 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Execution timed out 5097 ms 73824 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Execution timed out 5097 ms 73824 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Runtime error 1392 ms 524288 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Execution timed out 5058 ms 76352 KB Time limit exceeded
3 Halted 0 ms 0 KB -