Submission #154801

# Submission time Handle Problem Language Result Execution time Memory
154801 2019-09-24T17:52:17 Z Akashi Strange Device (APIO19_strange_device) C++14
5 / 100
2744 ms 53344 KB
#include <bits/stdc++.h>
using namespace std;

struct interv{
    long long l, r;
    bool operator < (const interv &aux)const{
        if(l != aux.l) return l < aux.l;
        return r < aux.r;
    }
};

interv a[1000005];

int n;
long long A, B;

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

    long long lg1 = log2(A), lg2 = log2(B);
    long long prod = 0;
    if(lg1 + lg2 <= 63) prod = 1LL * A * B;

    int m = n;
    for(int i = 1; i <= n ; ++i){
        cin >> a[i].l >> a[i].r;
        if(prod != 0){
            a[i].l %= prod, a[i].r %= prod;
            if(a[i].r < a[i].l) a[++m].l = 0, a[m].r = a[i].r, a[i].r = prod - 1;
        }
    }

    n = m;

    sort(a + 1, a + n + 1);

    long long Sol = 0, l = -2, r = -3;
    for(int i = 1; i <= n ; ++i){
        if(r < a[i].l){
            Sol = Sol + (r - l + 1);
            l = a[i].l; r = a[i].r;
        }
        else r = max(r, a[i].r);
    }

    Sol = Sol + (r - l + 1);

    cout << Sol;

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 28 ms 892 KB Output is correct
3 Correct 29 ms 764 KB Output is correct
4 Incorrect 2 ms 256 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 380 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 1879 ms 41164 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 400 KB Output is correct
2 Correct 2647 ms 53256 KB Output is correct
3 Incorrect 2651 ms 53236 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 400 KB Output is correct
2 Correct 2647 ms 53256 KB Output is correct
3 Incorrect 2651 ms 53236 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 400 KB Output is correct
2 Correct 2647 ms 53256 KB Output is correct
3 Incorrect 2651 ms 53236 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 268 ms 5596 KB Output is correct
3 Correct 269 ms 5628 KB Output is correct
4 Correct 2744 ms 53344 KB Output is correct
5 Correct 268 ms 5788 KB Output is correct
6 Correct 269 ms 5624 KB Output is correct
7 Correct 268 ms 5596 KB Output is correct
8 Correct 271 ms 5752 KB Output is correct
9 Correct 268 ms 5780 KB Output is correct
10 Correct 269 ms 5628 KB Output is correct
11 Correct 271 ms 5652 KB Output is correct
12 Correct 265 ms 5740 KB Output is correct
13 Correct 273 ms 5636 KB Output is correct
14 Correct 2686 ms 53288 KB Output is correct
15 Incorrect 269 ms 5724 KB Output isn't correct
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 28 ms 892 KB Output is correct
3 Correct 29 ms 764 KB Output is correct
4 Incorrect 2 ms 256 KB Output isn't correct
5 Halted 0 ms 0 KB -