답안 #765132

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
765132 2023-06-24T08:33:22 Z Kryz Art Exhibition (JOI18_art) C++17
100 / 100
423 ms 12352 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fi first
#define se second
#define sst string
#define pb push_back
#define maxco 100000+5
#define lld long double
#define cha ios_base::sync_with_stdio(false);
#define ffl cout.flush();
#define phi acos(-1)
#define mod 707
#define mr make_pair
#define pqin priority_queue<ll,vector<ll>,greater<>>
#define pqpair priority_queue<pair<ll,ll> ,vector<pair<ll,ll>>,greater<pair<ll,ll>>>
#define pqpair2 priority_queue<pair<pair<ll,ll>,pair<ll,ll>>,vector<pair<pi,pair<ll,ll>>>,greater<pair<pi,pair<ll,ll>>>>
#define INF 1000000009
#define MAXN 500069
#define pi pair<ll,ll>
ll mvx[]={1,-1,0,0};
ll mvy[]={0,0,1,-1};

pair<ll,ll> pr[MAXN];
ll ps[MAXN];
int main(){
    ll n;
    cin>>n;
    set<ll> st;
    for(ll i=1;i<=n;i++){
        cin>>pr[i].fi>>pr[i].se;
    }
    sort(pr+1,pr+n+1);
    ll mn=-1e18;
    ll ans=0;
    for(ll i=1;i<=n;i++){
        ps[i]+=ps[i-1]+pr[i].se;
    }
    for(ll i=1;i<=n;i++){
        mn=max(mn,pr[i].fi-ps[i-1]);
        ans=max(ans,ps[i]-pr[i].fi+mn);
    }
    cout<<ans<<endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 304 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 304 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 308 KB Output is correct
11 Correct 0 ms 308 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 304 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 304 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 308 KB Output is correct
11 Correct 0 ms 308 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 308 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 304 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 304 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 308 KB Output is correct
11 Correct 0 ms 308 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 308 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 4 ms 448 KB Output is correct
28 Correct 4 ms 468 KB Output is correct
29 Correct 4 ms 468 KB Output is correct
30 Correct 5 ms 468 KB Output is correct
31 Correct 6 ms 512 KB Output is correct
32 Correct 4 ms 444 KB Output is correct
33 Correct 4 ms 468 KB Output is correct
34 Correct 4 ms 468 KB Output is correct
35 Correct 4 ms 468 KB Output is correct
36 Correct 4 ms 468 KB Output is correct
37 Correct 4 ms 468 KB Output is correct
38 Correct 4 ms 468 KB Output is correct
39 Correct 4 ms 472 KB Output is correct
40 Correct 4 ms 444 KB Output is correct
41 Correct 4 ms 468 KB Output is correct
42 Correct 4 ms 552 KB Output is correct
43 Correct 6 ms 480 KB Output is correct
44 Correct 5 ms 468 KB Output is correct
45 Correct 4 ms 468 KB Output is correct
46 Correct 4 ms 468 KB Output is correct
47 Correct 4 ms 560 KB Output is correct
48 Correct 6 ms 596 KB Output is correct
49 Correct 4 ms 468 KB Output is correct
50 Correct 4 ms 448 KB Output is correct
51 Correct 4 ms 552 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 304 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 304 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 308 KB Output is correct
11 Correct 0 ms 308 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 308 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 4 ms 448 KB Output is correct
28 Correct 4 ms 468 KB Output is correct
29 Correct 4 ms 468 KB Output is correct
30 Correct 5 ms 468 KB Output is correct
31 Correct 6 ms 512 KB Output is correct
32 Correct 4 ms 444 KB Output is correct
33 Correct 4 ms 468 KB Output is correct
34 Correct 4 ms 468 KB Output is correct
35 Correct 4 ms 468 KB Output is correct
36 Correct 4 ms 468 KB Output is correct
37 Correct 4 ms 468 KB Output is correct
38 Correct 4 ms 468 KB Output is correct
39 Correct 4 ms 472 KB Output is correct
40 Correct 4 ms 444 KB Output is correct
41 Correct 4 ms 468 KB Output is correct
42 Correct 4 ms 552 KB Output is correct
43 Correct 6 ms 480 KB Output is correct
44 Correct 5 ms 468 KB Output is correct
45 Correct 4 ms 468 KB Output is correct
46 Correct 4 ms 468 KB Output is correct
47 Correct 4 ms 560 KB Output is correct
48 Correct 6 ms 596 KB Output is correct
49 Correct 4 ms 468 KB Output is correct
50 Correct 4 ms 448 KB Output is correct
51 Correct 4 ms 552 KB Output is correct
52 Correct 375 ms 12236 KB Output is correct
53 Correct 383 ms 12352 KB Output is correct
54 Correct 374 ms 12188 KB Output is correct
55 Correct 381 ms 12300 KB Output is correct
56 Correct 378 ms 12264 KB Output is correct
57 Correct 406 ms 12224 KB Output is correct
58 Correct 379 ms 12272 KB Output is correct
59 Correct 395 ms 12244 KB Output is correct
60 Correct 378 ms 12204 KB Output is correct
61 Correct 375 ms 12236 KB Output is correct
62 Correct 375 ms 12268 KB Output is correct
63 Correct 401 ms 12280 KB Output is correct
64 Correct 423 ms 12180 KB Output is correct
65 Correct 376 ms 12324 KB Output is correct
66 Correct 422 ms 12216 KB Output is correct
67 Correct 380 ms 12288 KB Output is correct
68 Correct 375 ms 12208 KB Output is correct