Submission #729553

# Submission time Handle Problem Language Result Execution time Memory
729553 2023-04-24T09:04:31 Z danikoynov Strange Device (APIO19_strange_device) C++14
15 / 100
5000 ms 524288 KB
#include<bits/stdc++.h>
#define endl '\n'

using namespace std;
typedef long long ll;

void speed()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

const int maxn = 1e6 + 10;

int n;
ll l[maxn], r[maxn];
ll A, B;


void solve()
{
    cin >> n >> A >> B;
    for (int i = 1; i <= n; i ++)
    {
        cin >> l[i] >> r[i];
    }
    if (n == 1)
    {
        ll ans = (r[1] - l[1] + 1);
        if (ans / B > A)
            ans = min(ans, A * B);
        cout << ans << endl;
        return;
    }
    unordered_set < ll > st;
    for (int i = 1; i <= n; i ++)
    {

        for (ll j = l[i]; j <= r[i]; j ++)
        {
            ll x = (j + (j / B)) % A, y = j % B;
            st.insert({x * B + y});
        }
    }

    cout << st.size() << endl;
}

int main()
{
    solve();
    return 0;
}
/**
7 3
4 1 3 4 0 2 3
*/
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 44 ms 9908 KB Output is correct
3 Correct 55 ms 12004 KB Output is correct
4 Correct 1 ms 596 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 3 ms 852 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 16 ms 4964 KB Output is correct
16 Correct 22 ms 5104 KB Output is correct
17 Correct 140 ms 6456 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 60 ms 21868 KB Output is correct
3 Correct 86 ms 21676 KB Output is correct
4 Correct 63 ms 20984 KB Output is correct
5 Execution timed out 5053 ms 58408 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1336 ms 58568 KB Output is correct
3 Runtime error 2165 ms 524288 KB Execution killed with signal 9
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1336 ms 58568 KB Output is correct
3 Runtime error 2165 ms 524288 KB Execution killed with signal 9
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1336 ms 58568 KB Output is correct
3 Runtime error 2165 ms 524288 KB Execution killed with signal 9
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Runtime error 2767 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 Correct 44 ms 9908 KB Output is correct
3 Correct 55 ms 12004 KB Output is correct
4 Correct 1 ms 596 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 3 ms 852 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 16 ms 4964 KB Output is correct
16 Correct 22 ms 5104 KB Output is correct
17 Correct 140 ms 6456 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 60 ms 21868 KB Output is correct
26 Correct 86 ms 21676 KB Output is correct
27 Correct 63 ms 20984 KB Output is correct
28 Execution timed out 5053 ms 58408 KB Time limit exceeded
29 Halted 0 ms 0 KB -