Submission #646046

# Submission time Handle Problem Language Result Execution time Memory
646046 2022-09-28T14:22:32 Z Tenis0206 Strange Device (APIO19_strange_device) C++11
35 / 100
628 ms 68964 KB
#include <bits/stdc++.h>
#define int long long

using namespace std;

int n,a,b;

vector<pair<int,int>> eves;

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n>>a>>b;
    int div = a * b / __gcd(b + 1, a);
    bool done = false;
    for(int i=1;i<=n;i++)
    {
        int l,r;
        cin>>l>>r;
        if(r - l + 1 >= div)
        {
            done = true;
        }
        l %= div;
        r %= div;
        if(l <= r)
        {
            eves.push_back({l,1});
            eves.push_back({r+1,-1});
        }
        else
        {
            eves.push_back({0,1});
            eves.push_back({r+1,-1});
            eves.push_back({l,1});
            eves.push_back({div,-1});
        }
    }
    if(done)
    {
        cout<<div<<'\n';
        return 0;
    }
    sort(eves.begin(),eves.end());
    int nr = 0;
    int rez = 0;
    int last = 0;
    for(auto it : eves)
    {
        if(nr==0 && it.second==1)
        {
            last = it.first;
        }
        nr += it.second;
        if(nr==0 && it.second==-1)
        {
            rez += it.first - last;
        }
    }
    cout<<rez<<'\n';
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 5 ms 856 KB Output is correct
3 Correct 5 ms 856 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 320 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 324 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 6 ms 1240 KB Output is correct
17 Correct 56 ms 7292 KB Output is correct
18 Incorrect 1 ms 320 KB Output isn't correct
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Incorrect 0 ms 212 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 328 ms 33320 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 505 ms 33276 KB Output is correct
3 Correct 503 ms 33252 KB Output is correct
4 Correct 517 ms 68920 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 505 ms 33276 KB Output is correct
3 Correct 503 ms 33252 KB Output is correct
4 Correct 517 ms 68920 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 564 ms 68932 KB Output is correct
7 Correct 487 ms 68920 KB Output is correct
8 Correct 514 ms 68892 KB Output is correct
9 Correct 609 ms 68920 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 505 ms 33276 KB Output is correct
3 Correct 503 ms 33252 KB Output is correct
4 Correct 517 ms 68920 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 63 ms 7260 KB Output is correct
7 Correct 57 ms 7236 KB Output is correct
8 Correct 52 ms 7264 KB Output is correct
9 Correct 52 ms 7284 KB Output is correct
10 Correct 47 ms 7240 KB Output is correct
11 Correct 52 ms 7172 KB Output is correct
12 Correct 63 ms 7232 KB Output is correct
13 Correct 72 ms 7236 KB Output is correct
14 Correct 61 ms 7204 KB Output is correct
15 Correct 56 ms 7236 KB Output is correct
16 Correct 58 ms 7192 KB Output is correct
17 Correct 50 ms 7284 KB Output is correct
18 Correct 562 ms 68812 KB Output is correct
19 Correct 526 ms 68964 KB Output is correct
20 Correct 628 ms 68840 KB Output is correct
21 Correct 72 ms 7236 KB Output is correct
22 Correct 45 ms 7284 KB Output is correct
23 Correct 147 ms 26696 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 54 ms 4764 KB Output is correct
3 Correct 58 ms 4828 KB Output is correct
4 Correct 621 ms 33204 KB Output is correct
5 Correct 52 ms 4716 KB Output is correct
6 Correct 55 ms 4760 KB Output is correct
7 Correct 76 ms 4784 KB Output is correct
8 Correct 55 ms 4796 KB Output is correct
9 Correct 53 ms 4800 KB Output is correct
10 Correct 68 ms 4688 KB Output is correct
11 Correct 70 ms 4800 KB Output is correct
12 Correct 46 ms 4760 KB Output is correct
13 Correct 54 ms 4780 KB Output is correct
14 Correct 563 ms 33176 KB Output is correct
15 Correct 54 ms 4804 KB Output is correct
16 Correct 477 ms 68848 KB Output is correct
17 Correct 502 ms 68908 KB Output is correct
18 Incorrect 0 ms 212 KB Output isn't correct
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 5 ms 856 KB Output is correct
3 Correct 5 ms 856 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 320 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 324 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 6 ms 1240 KB Output is correct
17 Correct 56 ms 7292 KB Output is correct
18 Incorrect 1 ms 320 KB Output isn't correct
19 Halted 0 ms 0 KB -