답안 #1108443

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1108443 2024-11-04T07:02:33 Z vjudge1 Art Exhibition (JOI18_art) C++17
100 / 100
280 ms 21936 KB
#include <bits/stdc++.h>
#define ll long long
#define cst const long long
#define ff first
#define ss second
using namespace std;
ll o,d,m,n,a1,a2,a3,l,r,i,j,x,y,u,v,k,w,z,M,q,p[500005],f[2000005];
cst mod=1e9+7;
pair<ll,ll> a[500005];
void up(ll id,ll l,ll r,ll i,ll v)
{
    if(i<l || i>r) return;
    if(l==r)
    {
        f[id]=v;
        return;
    }
    ll mid=(l+r)/2;
    up(id*2,l,mid,i,v); up(id*2+1,mid+1,r,i,v);
    f[id]=max(f[id*2],f[id*2+1]);
}
ll lay(ll id,ll l,ll r,ll u,ll v)
{
    if(l>r) return 0;
    if(v<l || r<u) return 0;
    if(u<=l && v>=r) return f[id];
    ll mid=(l+r)/2;
    return max(lay(id*2,l,mid,u,v),lay(id*2+1,mid+1,r,u,v));
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    cin >> n;
    for(ll i=1;i<=n;i++) cin >> a[i].ff >> a[i].ss;
    sort(a+1,a+1+n);
    for(ll i=n;i>=1;i--) p[i]=p[i+1]+a[i].ss;
    for(ll i=1;i<=n;i++)
    {
        d=max(lay(1,1,n,1,i-1),p[i]+a[i].ff);
        w=max(w,d-p[i+1]-a[i].ff);
        up(1,1,n,i,p[i]+a[i].ff);
    }
    cout << w;
}

# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2384 KB Output is correct
2 Correct 1 ms 2384 KB Output is correct
3 Correct 1 ms 2384 KB Output is correct
4 Correct 1 ms 2384 KB Output is correct
5 Correct 1 ms 2384 KB Output is correct
6 Correct 2 ms 2384 KB Output is correct
7 Correct 1 ms 2552 KB Output is correct
8 Correct 1 ms 2384 KB Output is correct
9 Correct 1 ms 2384 KB Output is correct
10 Correct 1 ms 2384 KB Output is correct
11 Correct 2 ms 2384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2384 KB Output is correct
2 Correct 1 ms 2384 KB Output is correct
3 Correct 1 ms 2384 KB Output is correct
4 Correct 1 ms 2384 KB Output is correct
5 Correct 1 ms 2384 KB Output is correct
6 Correct 2 ms 2384 KB Output is correct
7 Correct 1 ms 2552 KB Output is correct
8 Correct 1 ms 2384 KB Output is correct
9 Correct 1 ms 2384 KB Output is correct
10 Correct 1 ms 2384 KB Output is correct
11 Correct 2 ms 2384 KB Output is correct
12 Correct 1 ms 2384 KB Output is correct
13 Correct 1 ms 2384 KB Output is correct
14 Correct 1 ms 2388 KB Output is correct
15 Correct 1 ms 2384 KB Output is correct
16 Correct 2 ms 2384 KB Output is correct
17 Correct 1 ms 2384 KB Output is correct
18 Correct 1 ms 2404 KB Output is correct
19 Correct 1 ms 2384 KB Output is correct
20 Correct 1 ms 2384 KB Output is correct
21 Correct 1 ms 2384 KB Output is correct
22 Correct 1 ms 2384 KB Output is correct
23 Correct 1 ms 2384 KB Output is correct
24 Correct 1 ms 2524 KB Output is correct
25 Correct 1 ms 2384 KB Output is correct
26 Correct 1 ms 2384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2384 KB Output is correct
2 Correct 1 ms 2384 KB Output is correct
3 Correct 1 ms 2384 KB Output is correct
4 Correct 1 ms 2384 KB Output is correct
5 Correct 1 ms 2384 KB Output is correct
6 Correct 2 ms 2384 KB Output is correct
7 Correct 1 ms 2552 KB Output is correct
8 Correct 1 ms 2384 KB Output is correct
9 Correct 1 ms 2384 KB Output is correct
10 Correct 1 ms 2384 KB Output is correct
11 Correct 2 ms 2384 KB Output is correct
12 Correct 1 ms 2384 KB Output is correct
13 Correct 1 ms 2384 KB Output is correct
14 Correct 1 ms 2388 KB Output is correct
15 Correct 1 ms 2384 KB Output is correct
16 Correct 2 ms 2384 KB Output is correct
17 Correct 1 ms 2384 KB Output is correct
18 Correct 1 ms 2404 KB Output is correct
19 Correct 1 ms 2384 KB Output is correct
20 Correct 1 ms 2384 KB Output is correct
21 Correct 1 ms 2384 KB Output is correct
22 Correct 1 ms 2384 KB Output is correct
23 Correct 1 ms 2384 KB Output is correct
24 Correct 1 ms 2524 KB Output is correct
25 Correct 1 ms 2384 KB Output is correct
26 Correct 1 ms 2384 KB Output is correct
27 Correct 3 ms 2640 KB Output is correct
28 Correct 3 ms 2640 KB Output is correct
29 Correct 3 ms 2640 KB Output is correct
30 Correct 4 ms 2812 KB Output is correct
31 Correct 3 ms 2640 KB Output is correct
32 Correct 3 ms 2640 KB Output is correct
33 Correct 3 ms 2808 KB Output is correct
34 Correct 3 ms 2640 KB Output is correct
35 Correct 3 ms 2640 KB Output is correct
36 Correct 3 ms 2640 KB Output is correct
37 Correct 3 ms 2640 KB Output is correct
38 Correct 3 ms 2640 KB Output is correct
39 Correct 4 ms 2656 KB Output is correct
40 Correct 4 ms 2640 KB Output is correct
41 Correct 3 ms 2644 KB Output is correct
42 Correct 3 ms 2636 KB Output is correct
43 Correct 4 ms 2640 KB Output is correct
44 Correct 3 ms 2808 KB Output is correct
45 Correct 3 ms 2640 KB Output is correct
46 Correct 3 ms 2640 KB Output is correct
47 Correct 3 ms 2804 KB Output is correct
48 Correct 3 ms 2640 KB Output is correct
49 Correct 3 ms 2640 KB Output is correct
50 Correct 4 ms 2640 KB Output is correct
51 Correct 3 ms 2640 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2384 KB Output is correct
2 Correct 1 ms 2384 KB Output is correct
3 Correct 1 ms 2384 KB Output is correct
4 Correct 1 ms 2384 KB Output is correct
5 Correct 1 ms 2384 KB Output is correct
6 Correct 2 ms 2384 KB Output is correct
7 Correct 1 ms 2552 KB Output is correct
8 Correct 1 ms 2384 KB Output is correct
9 Correct 1 ms 2384 KB Output is correct
10 Correct 1 ms 2384 KB Output is correct
11 Correct 2 ms 2384 KB Output is correct
12 Correct 1 ms 2384 KB Output is correct
13 Correct 1 ms 2384 KB Output is correct
14 Correct 1 ms 2388 KB Output is correct
15 Correct 1 ms 2384 KB Output is correct
16 Correct 2 ms 2384 KB Output is correct
17 Correct 1 ms 2384 KB Output is correct
18 Correct 1 ms 2404 KB Output is correct
19 Correct 1 ms 2384 KB Output is correct
20 Correct 1 ms 2384 KB Output is correct
21 Correct 1 ms 2384 KB Output is correct
22 Correct 1 ms 2384 KB Output is correct
23 Correct 1 ms 2384 KB Output is correct
24 Correct 1 ms 2524 KB Output is correct
25 Correct 1 ms 2384 KB Output is correct
26 Correct 1 ms 2384 KB Output is correct
27 Correct 3 ms 2640 KB Output is correct
28 Correct 3 ms 2640 KB Output is correct
29 Correct 3 ms 2640 KB Output is correct
30 Correct 4 ms 2812 KB Output is correct
31 Correct 3 ms 2640 KB Output is correct
32 Correct 3 ms 2640 KB Output is correct
33 Correct 3 ms 2808 KB Output is correct
34 Correct 3 ms 2640 KB Output is correct
35 Correct 3 ms 2640 KB Output is correct
36 Correct 3 ms 2640 KB Output is correct
37 Correct 3 ms 2640 KB Output is correct
38 Correct 3 ms 2640 KB Output is correct
39 Correct 4 ms 2656 KB Output is correct
40 Correct 4 ms 2640 KB Output is correct
41 Correct 3 ms 2644 KB Output is correct
42 Correct 3 ms 2636 KB Output is correct
43 Correct 4 ms 2640 KB Output is correct
44 Correct 3 ms 2808 KB Output is correct
45 Correct 3 ms 2640 KB Output is correct
46 Correct 3 ms 2640 KB Output is correct
47 Correct 3 ms 2804 KB Output is correct
48 Correct 3 ms 2640 KB Output is correct
49 Correct 3 ms 2640 KB Output is correct
50 Correct 4 ms 2640 KB Output is correct
51 Correct 3 ms 2640 KB Output is correct
52 Correct 264 ms 21688 KB Output is correct
53 Correct 229 ms 21576 KB Output is correct
54 Correct 248 ms 21936 KB Output is correct
55 Correct 259 ms 21636 KB Output is correct
56 Correct 280 ms 21628 KB Output is correct
57 Correct 272 ms 21636 KB Output is correct
58 Correct 224 ms 21636 KB Output is correct
59 Correct 238 ms 21632 KB Output is correct
60 Correct 239 ms 21632 KB Output is correct
61 Correct 242 ms 21576 KB Output is correct
62 Correct 220 ms 21576 KB Output is correct
63 Correct 269 ms 21628 KB Output is correct
64 Correct 225 ms 21636 KB Output is correct
65 Correct 231 ms 21576 KB Output is correct
66 Correct 251 ms 21640 KB Output is correct
67 Correct 242 ms 21576 KB Output is correct
68 Correct 254 ms 21576 KB Output is correct