Submission #712752

# Submission time Handle Problem Language Result Execution time Memory
712752 2023-03-19T17:05:53 Z HuyQuang_re_Zero Strange Device (APIO19_strange_device) C++14
10 / 100
671 ms 68940 KB
#include <bits/stdc++.h>
#define ll long long
#define db long double
#define N 4000002
#define II pair <ll,ll>
#define fst first
#define snd second
using namespace std;
ll n,a,b,l,r,m,i;
II c[N];
void sub1()
{
    ll res=0;
    for(i=1;i<=n;i++) cin>>l>>r,res+=(r-l+1);
    cout<<res;
}
void add(ll l,ll r) { c[++m]={ l,1 }; c[++m]={ r,-1 }; }
void sub2()
{
    for(i=1;i<=n;i++)
    {
        cin>>l>>r;
        if(r-l+1>=a*b) { cout<<a*b; return ; }
        l=l%(a*b); r=r%(a*b);
        if(l<=r) add(l,r);
        else add(l,a*b-1),add(0,r);
    }
    sort(c+1,c+m+1);
    c[0]={ -1,1 };
    ll cnt=0,res=0;
    for(i=1;i<=m;i++)
    {
        if(c[i].fst>c[i-1].fst)
        {
            if(cnt>0) res+=c[i].fst-c[i-1].fst;
            else res++;
        }
        cnt+=c[i].snd;
    }
    cout<<res;
}
int main()
{
   // freopen("ntu.inp","r",stdin);
    //freopen("ntu.out","w",stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin>>n>>a>>b;
    if(b>round(1e18)/a) sub1();
    else sub2();
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 5 ms 976 KB Output is correct
3 Correct 5 ms 920 KB Output is correct
4 Incorrect 1 ms 212 KB Output isn't correct
5 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 1 ms 212 KB Output is correct
4 Correct 1 ms 324 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
# 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 332 ms 56856 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 507 ms 68820 KB Output is correct
3 Incorrect 468 ms 68696 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 507 ms 68820 KB Output is correct
3 Incorrect 468 ms 68696 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 507 ms 68820 KB Output is correct
3 Incorrect 468 ms 68696 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 54 ms 7132 KB Output is correct
3 Correct 64 ms 7068 KB Output is correct
4 Correct 671 ms 68940 KB Output is correct
5 Correct 51 ms 7116 KB Output is correct
6 Correct 52 ms 7164 KB Output is correct
7 Correct 59 ms 7140 KB Output is correct
8 Correct 58 ms 7096 KB Output is correct
9 Correct 54 ms 7168 KB Output is correct
10 Correct 60 ms 7052 KB Output is correct
11 Correct 50 ms 7116 KB Output is correct
12 Correct 58 ms 7168 KB Output is correct
13 Correct 56 ms 7164 KB Output is correct
14 Correct 570 ms 68876 KB Output is correct
15 Incorrect 56 ms 7148 KB Output isn't correct
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 5 ms 976 KB Output is correct
3 Correct 5 ms 920 KB Output is correct
4 Incorrect 1 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -