Submission #997696

# Submission time Handle Problem Language Result Execution time Memory
997696 2024-06-12T17:47:19 Z I_FloPPed21 Art Exhibition (JOI18_art) C++14
100 / 100
610 ms 40020 KB
#include <iostream>
#include <algorithm>
using namespace std;
int n;
struct arta
{
    long long x, y;
}v[500005];

long long seg[2000005],lz[2000005];

void update( int nod , int st, int dr, int l ,int r , long long val )
{
    if( l <= st && dr <= r )
    {
        lz[nod] += val ;
        seg[nod] += val ;
    }
    else
        if( l > dr || st > r )
        return ;
    else
    {
        int mij = ( st +dr ) / 2;
        lz[nod*2] += lz[nod],seg[nod*2]+= lz[nod];
        lz[nod*2+1] += lz[nod],seg[nod*2+1] += lz[nod];
        lz[nod] = 0 ;
        update(nod*2,st,mij,l,r,val) ;
        update(nod*2+1,mij+1,dr,l,r,val);
        seg[nod] = max( seg[nod*2],seg[nod*2+1]);
    }
}

long long query(int nod ,int st , int dr ,int l , int r )
{
    if( l <= st && dr <= r )
        return seg[nod];
    else
        if( st > r || dr < l )
        return -1e18;
    else
    {
        int mij = ( st + dr ) / 2;
        lz[nod*2] += lz[nod],lz[nod*2+1]+= lz[nod];
        seg[nod*2] += lz[nod],seg[nod*2+1] += lz[nod];
        lz[nod] = 0 ;
        return max(query(nod*2,st,mij,l,r),query(nod*2+1,mij+1,dr,l,r));
    }
}
bool tdl ( arta x , arta y )
{
    return ( x.x < y.x);
}
int main()
{
    cin >> n ;
    for (int i = 1; i <= n ; i ++ )
        cin >> v[i].x>>v[i].y;
    sort(v+1,v+n+1,tdl);

    long long ans = 0;
    for ( int i = 1 ; i <= n ;i ++ )
    {
        update(1,1,n,1,i,v[i].y);
       if ( i != 1 )
            update(1,1,n,1,i - 1 ,-(v[i].x - v[i-1].x));

            //cout << query(1,1,n,1,1)<< '\n';
        ans = max ( ans , query(1,1,n,1,i));
    }
    cout << ans << '\n';
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4440 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4440 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 1 ms 4444 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4440 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4440 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 1 ms 4444 KB Output is correct
12 Correct 1 ms 4444 KB Output is correct
13 Correct 1 ms 4548 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 1 ms 4444 KB Output is correct
16 Correct 1 ms 4536 KB Output is correct
17 Correct 1 ms 4444 KB Output is correct
18 Correct 1 ms 4700 KB Output is correct
19 Correct 1 ms 4444 KB Output is correct
20 Correct 1 ms 4444 KB Output is correct
21 Correct 1 ms 4444 KB Output is correct
22 Correct 1 ms 4444 KB Output is correct
23 Correct 1 ms 4444 KB Output is correct
24 Correct 1 ms 4444 KB Output is correct
25 Correct 1 ms 4444 KB Output is correct
26 Correct 1 ms 4440 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4440 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4440 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 1 ms 4444 KB Output is correct
12 Correct 1 ms 4444 KB Output is correct
13 Correct 1 ms 4548 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 1 ms 4444 KB Output is correct
16 Correct 1 ms 4536 KB Output is correct
17 Correct 1 ms 4444 KB Output is correct
18 Correct 1 ms 4700 KB Output is correct
19 Correct 1 ms 4444 KB Output is correct
20 Correct 1 ms 4444 KB Output is correct
21 Correct 1 ms 4444 KB Output is correct
22 Correct 1 ms 4444 KB Output is correct
23 Correct 1 ms 4444 KB Output is correct
24 Correct 1 ms 4444 KB Output is correct
25 Correct 1 ms 4444 KB Output is correct
26 Correct 1 ms 4440 KB Output is correct
27 Correct 6 ms 4700 KB Output is correct
28 Correct 5 ms 4648 KB Output is correct
29 Correct 5 ms 4700 KB Output is correct
30 Correct 6 ms 4700 KB Output is correct
31 Correct 5 ms 4700 KB Output is correct
32 Correct 5 ms 4700 KB Output is correct
33 Correct 6 ms 4700 KB Output is correct
34 Correct 7 ms 4652 KB Output is correct
35 Correct 5 ms 4556 KB Output is correct
36 Correct 5 ms 4700 KB Output is correct
37 Correct 6 ms 4700 KB Output is correct
38 Correct 6 ms 4700 KB Output is correct
39 Correct 5 ms 4700 KB Output is correct
40 Correct 5 ms 4696 KB Output is correct
41 Correct 6 ms 4716 KB Output is correct
42 Correct 5 ms 4652 KB Output is correct
43 Correct 6 ms 4700 KB Output is correct
44 Correct 5 ms 4556 KB Output is correct
45 Correct 5 ms 4672 KB Output is correct
46 Correct 6 ms 4700 KB Output is correct
47 Correct 5 ms 4700 KB Output is correct
48 Correct 5 ms 4700 KB Output is correct
49 Correct 5 ms 4700 KB Output is correct
50 Correct 5 ms 4700 KB Output is correct
51 Correct 5 ms 4700 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4440 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4440 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 1 ms 4444 KB Output is correct
12 Correct 1 ms 4444 KB Output is correct
13 Correct 1 ms 4548 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 1 ms 4444 KB Output is correct
16 Correct 1 ms 4536 KB Output is correct
17 Correct 1 ms 4444 KB Output is correct
18 Correct 1 ms 4700 KB Output is correct
19 Correct 1 ms 4444 KB Output is correct
20 Correct 1 ms 4444 KB Output is correct
21 Correct 1 ms 4444 KB Output is correct
22 Correct 1 ms 4444 KB Output is correct
23 Correct 1 ms 4444 KB Output is correct
24 Correct 1 ms 4444 KB Output is correct
25 Correct 1 ms 4444 KB Output is correct
26 Correct 1 ms 4440 KB Output is correct
27 Correct 6 ms 4700 KB Output is correct
28 Correct 5 ms 4648 KB Output is correct
29 Correct 5 ms 4700 KB Output is correct
30 Correct 6 ms 4700 KB Output is correct
31 Correct 5 ms 4700 KB Output is correct
32 Correct 5 ms 4700 KB Output is correct
33 Correct 6 ms 4700 KB Output is correct
34 Correct 7 ms 4652 KB Output is correct
35 Correct 5 ms 4556 KB Output is correct
36 Correct 5 ms 4700 KB Output is correct
37 Correct 6 ms 4700 KB Output is correct
38 Correct 6 ms 4700 KB Output is correct
39 Correct 5 ms 4700 KB Output is correct
40 Correct 5 ms 4696 KB Output is correct
41 Correct 6 ms 4716 KB Output is correct
42 Correct 5 ms 4652 KB Output is correct
43 Correct 6 ms 4700 KB Output is correct
44 Correct 5 ms 4556 KB Output is correct
45 Correct 5 ms 4672 KB Output is correct
46 Correct 6 ms 4700 KB Output is correct
47 Correct 5 ms 4700 KB Output is correct
48 Correct 5 ms 4700 KB Output is correct
49 Correct 5 ms 4700 KB Output is correct
50 Correct 5 ms 4700 KB Output is correct
51 Correct 5 ms 4700 KB Output is correct
52 Correct 562 ms 39760 KB Output is correct
53 Correct 566 ms 39708 KB Output is correct
54 Correct 561 ms 39832 KB Output is correct
55 Correct 610 ms 39760 KB Output is correct
56 Correct 566 ms 39764 KB Output is correct
57 Correct 576 ms 39848 KB Output is correct
58 Correct 568 ms 39760 KB Output is correct
59 Correct 556 ms 39764 KB Output is correct
60 Correct 581 ms 39716 KB Output is correct
61 Correct 562 ms 39540 KB Output is correct
62 Correct 594 ms 40020 KB Output is correct
63 Correct 556 ms 39704 KB Output is correct
64 Correct 562 ms 39848 KB Output is correct
65 Correct 559 ms 39824 KB Output is correct
66 Correct 571 ms 39764 KB Output is correct
67 Correct 559 ms 39760 KB Output is correct
68 Correct 560 ms 39804 KB Output is correct