Submission #646044

# Submission time Handle Problem Language Result Execution time Memory
646044 2022-09-28T14:21:02 Z Tenis0206 Strange Device (APIO19_strange_device) C++11
5 / 100
606 ms 33548 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;
    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 1 ms 212 KB Output is correct
2 Correct 7 ms 984 KB Output is correct
3 Correct 7 ms 856 KB Output is correct
4 Incorrect 0 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 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 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 331 ms 33172 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 501 ms 33216 KB Output is correct
3 Incorrect 429 ms 33252 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 501 ms 33216 KB Output is correct
3 Incorrect 429 ms 33252 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 501 ms 33216 KB Output is correct
3 Incorrect 429 ms 33252 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 54 ms 4512 KB Output is correct
3 Correct 50 ms 4556 KB Output is correct
4 Correct 606 ms 33280 KB Output is correct
5 Correct 53 ms 4440 KB Output is correct
6 Correct 59 ms 4568 KB Output is correct
7 Correct 55 ms 4548 KB Output is correct
8 Correct 51 ms 4556 KB Output is correct
9 Correct 48 ms 4528 KB Output is correct
10 Correct 53 ms 4528 KB Output is correct
11 Correct 50 ms 4548 KB Output is correct
12 Correct 55 ms 4512 KB Output is correct
13 Correct 57 ms 4576 KB Output is correct
14 Correct 562 ms 33548 KB Output is correct
15 Incorrect 54 ms 4572 KB Output isn't correct
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 7 ms 984 KB Output is correct
3 Correct 7 ms 856 KB Output is correct
4 Incorrect 0 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -