Submission #103429

# Submission time Handle Problem Language Result Execution time Memory
103429 2019-03-30T15:52:21 Z Alliance Art Exhibition (JOI18_art) C++14
0 / 100
3 ms 384 KB
// In the name of Allah. Ya ali!
#include<bits/stdc++.h>
#define double long double
typedef long long ll;
const ll MAX_N = 1.2e6+10;
const ll MOD = 1e9+7;
using namespace std;

ll mx[MAX_N];
ll fl[MAX_N];
pair<ll,ll> lr[MAX_N];
int n,y;

void shift(int k)
{
    int l = k*2;
    int r = k*2+1;
    fl[l] += fl[k];
    fl[r] += fl[k];
    mx[l] += fl[k];
    mx[r] += fl[k];
    fl[k] = 0;
}

void update(int k)
{
    mx[k] = max(mx[k*2],mx[k*2+1]);
}

void add(int l,int r,int a,int b,int k,ll x)
{
    if (r<a or b<l)
        return;
    if (a<=l and r<=b)
    {
        fl[k] += x;
        mx[k] += x;
        return;
    }
    int mid = (l+r)/2;
    shift(k);
    add(l,mid,a,b,k*2,x);
    add(mid+1,r,a,b,k*2+1,x);
    update(k);
}

int main()
{
    cin >> n;
    y = (1<<((int)ceil(log2(n))));
    ll ans = 0;
    for(int i = 0;i<n;++i)
        scanf("%I64d%I64d",&lr[i].first,&lr[i].second),ans = max(ans,lr[i].second);
    sort(lr,lr+n);
    add(0,y-1,0,0,1,lr[0].second);
    for(int i = 1;i<n;++i)
    {
        add(0,y-1,0,i-1,1,-lr[i].first+lr[i-1].first+lr[i].second);
        add(0,y-1,i,i,1,max(lr[i].second,mx[1]));
        ans = max(ans,mx[1]);
    }
    cout << ans;
    return 0;
}

Compilation message

art.cpp: In function 'int main()':
art.cpp:53:54: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long long int*' [-Wformat=]
         scanf("%I64d%I64d",&lr[i].first,&lr[i].second),ans = max(ans,lr[i].second);
                            ~~~~~~~~~~~~              ^
art.cpp:53:54: warning: format '%d' expects argument of type 'int*', but argument 3 has type 'long long int*' [-Wformat=]
art.cpp:53:55: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%I64d%I64d",&lr[i].first,&lr[i].second),ans = max(ans,lr[i].second);
         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -