Submission #561282

# Submission time Handle Problem Language Result Execution time Memory
561282 2022-05-12T15:08:14 Z baokhue232005 Strange Device (APIO19_strange_device) C++14
65 / 100
494 ms 31364 KB
/*
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimize("unroll-loops")
*/
// lethal option

#include<bits/stdc++.h>
using namespace std;

#define all(flg) flg.begin(), flg.end()
#define int long long
#define pb push_back
#define fi first
#define se second
#define endl "\n"
#define eb emplace_back
#define ii pair<int, int>
#define PI 3.141592653589793238462643383279502884
#define ll long long
#define for1(i, ff, gg) for(int i = ff; i <= gg; ++i)
#define for2(i, ff, gg) for(int i = ff; i >= gg; --i)
const ll mod = 1e9 + 7;
const int maxN = 1000005;
const ll oo = 1e18 + 7;
int n, a[maxN];
int x, y, z, k;
ii pr[maxN];

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    cin >> n >> x >> y;
    z = y * (x / __gcd(x, y + 1));
    set<ii> st;
    for1(i, 1, n){
        cin >> x >> y;
        pr[i].fi = x % z;
        pr[i].se = y % z;
    }
    for1(i, 1, n){
        if(pr[i].fi > pr[i].se){
            ++n;
            pr[n].se = pr[i].se;
            pr[n].fi = 0;
            pr[i].se = z - 1;
        }
    }
    int lmx = -oo;
    sort(pr + 1, pr + n + 1);
    int ans = 0;
    for1(i, 1, n){
        lmx = max(lmx, pr[i].fi - 1);
        ans += max(0ll, pr[i].se - lmx);
        lmx = max(lmx, pr[i].se);
    }
    cout << ans << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 6 ms 840 KB Output is correct
3 Correct 6 ms 748 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 0 ms 332 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 5 ms 852 KB Output is correct
17 Correct 56 ms 5580 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 328 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 299 ms 16932 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 474 ms 27444 KB Output is correct
3 Correct 421 ms 31364 KB Output is correct
4 Correct 390 ms 17156 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 474 ms 27444 KB Output is correct
3 Correct 421 ms 31364 KB Output is correct
4 Correct 390 ms 17156 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 408 ms 17348 KB Output is correct
7 Correct 374 ms 17276 KB Output is correct
8 Correct 396 ms 17268 KB Output is correct
9 Correct 436 ms 17152 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 474 ms 27444 KB Output is correct
3 Correct 421 ms 31364 KB Output is correct
4 Correct 390 ms 17156 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 45 ms 5496 KB Output is correct
7 Correct 41 ms 5580 KB Output is correct
8 Correct 43 ms 5576 KB Output is correct
9 Correct 42 ms 5524 KB Output is correct
10 Correct 43 ms 5492 KB Output is correct
11 Correct 59 ms 5512 KB Output is correct
12 Correct 41 ms 5576 KB Output is correct
13 Correct 43 ms 5512 KB Output is correct
14 Correct 43 ms 5580 KB Output is correct
15 Correct 47 ms 5528 KB Output is correct
16 Correct 52 ms 5540 KB Output is correct
17 Correct 44 ms 5548 KB Output is correct
18 Correct 420 ms 17252 KB Output is correct
19 Correct 393 ms 17304 KB Output is correct
20 Correct 460 ms 17348 KB Output is correct
21 Correct 46 ms 5572 KB Output is correct
22 Correct 43 ms 5492 KB Output is correct
23 Correct 127 ms 18200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 55 ms 5616 KB Output is correct
3 Correct 49 ms 5580 KB Output is correct
4 Correct 494 ms 31236 KB Output is correct
5 Correct 50 ms 5552 KB Output is correct
6 Correct 47 ms 5516 KB Output is correct
7 Correct 43 ms 5584 KB Output is correct
8 Correct 45 ms 5600 KB Output is correct
9 Correct 46 ms 5580 KB Output is correct
10 Correct 48 ms 5472 KB Output is correct
11 Correct 45 ms 5592 KB Output is correct
12 Correct 38 ms 5508 KB Output is correct
13 Correct 52 ms 5504 KB Output is correct
14 Correct 432 ms 17268 KB Output is correct
15 Correct 44 ms 5592 KB Output is correct
16 Correct 407 ms 17276 KB Output is correct
17 Correct 404 ms 17352 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 6 ms 840 KB Output is correct
3 Correct 6 ms 748 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 0 ms 332 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 5 ms 852 KB Output is correct
17 Correct 56 ms 5580 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Incorrect 1 ms 212 KB Output isn't correct
21 Halted 0 ms 0 KB -