Submission #217911

# Submission time Handle Problem Language Result Execution time Memory
217911 2020-03-31T08:15:33 Z Autoratch Strange Device (APIO19_strange_device) C++14
0 / 100
1328 ms 137428 KB
#include <bits/stdc++.h>
using namespace std;

const int N = 2e6 + 10;

int n;
long long a,b;
map<long long,int> ma;
set<long long> s;
int res[N];
vector<pair<long long,long long> > in;
long long rng[N],ans;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);

    cin >> n >> a >> b;
    for(int i = 0;i < n;i++)
    {
        long long x,y;
        cin >> x >> y; 
        if(y-x+1LL>=a*b){ cout << a*b; return 0; }
        y++;
        x%=(a*b),y%=(a*b); 
        if(y<x) in.push_back({0LL,y}),in.push_back({x,a*b});
        else in.push_back({x,y});
        s.insert(x),s.insert(y);
    }
    s.insert(0),s.insert(a*b);
    long long prev = 0;
    int id = 0;
    for(auto x : s) ma[x] = ++id,rng[id-1] = x-prev,prev = x;
    for(auto x : in) res[ma[x.first]]++,res[ma[x.second]]--;
    for(int i = 1;i < 10;i++) res[i]+=res[i-1];
    for(int i = 1;i < N;i++) if(res[i]) ans+=rng[i];
    cout << ans;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Incorrect 17 ms 2044 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 7 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Incorrect 5 ms 384 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Incorrect 8 ms 640 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Incorrect 1328 ms 137428 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Incorrect 1328 ms 137428 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Incorrect 1328 ms 137428 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Incorrect 137 ms 14436 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Incorrect 17 ms 2044 KB Output isn't correct
3 Halted 0 ms 0 KB -