답안 #164496

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
164496 2019-11-21T06:06:16 Z balbit Art Exhibition (JOI18_art) C++14
100 / 100
412 ms 24944 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define f first
#define s second
#define FOR(i,a,b) for (int i = a; i<b; i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for (int i = n-1; i>=0; i--)
#define SZ(x) (int)(x.size())
#define ALL(x) x.begin(),x.end()
#define MX(a,b) a = max(a,(__typeof__(a))(b))
#define MN(a,b) a = min(a,(__typeof__(a))(b))
#define pb push_back
#ifdef BALBIT
#define IOS()
#define bug(x) cerr<<__LINE__<<": "<<x<<endl
#else
#define IOS() ios::sync_with_stdio(0),cin.tie(0)
#define endl '\n'
#define bug(x)
#endif

const ll mod = 1e9+7;
const int maxn = 3e5;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int iinf = 0x3f3f3f3f;

struct pt{
	ll a, b;
};

signed main(){
	IOS();
	int n; cin>>n;
	vector<pt> v;
	REP(i,n){
		ll a, b; cin>>a>>b; v.pb({a,b});
	}
	sort(ALL(v), [](pt a, pt b){
		return a.a<b.a;
	});
	vector<ll>ps(n+1);
	ll mx = -INF;
	ll re = 0;
	REP(i,n){
		ps[i+1] = ps[i] + v[i].b;
		MX(mx, v[i].a-ps[i]);
		MX(re, ps[i+1] - v[i].a + mx);
		
	}
	cout<<re<<endl;
	
}

# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 380 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 380 KB Output is correct
9 Correct 2 ms 252 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 380 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 380 KB Output is correct
9 Correct 2 ms 252 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 380 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 380 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 2 ms 380 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 2 ms 348 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 380 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 380 KB Output is correct
9 Correct 2 ms 252 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 380 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 380 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 2 ms 380 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 2 ms 348 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 5 ms 632 KB Output is correct
28 Correct 4 ms 632 KB Output is correct
29 Correct 4 ms 688 KB Output is correct
30 Correct 5 ms 760 KB Output is correct
31 Correct 5 ms 632 KB Output is correct
32 Correct 4 ms 632 KB Output is correct
33 Correct 4 ms 632 KB Output is correct
34 Correct 5 ms 760 KB Output is correct
35 Correct 5 ms 632 KB Output is correct
36 Correct 5 ms 632 KB Output is correct
37 Correct 4 ms 632 KB Output is correct
38 Correct 5 ms 648 KB Output is correct
39 Correct 5 ms 632 KB Output is correct
40 Correct 5 ms 676 KB Output is correct
41 Correct 4 ms 632 KB Output is correct
42 Correct 4 ms 632 KB Output is correct
43 Correct 5 ms 632 KB Output is correct
44 Correct 5 ms 676 KB Output is correct
45 Correct 5 ms 632 KB Output is correct
46 Correct 5 ms 632 KB Output is correct
47 Correct 4 ms 676 KB Output is correct
48 Correct 5 ms 632 KB Output is correct
49 Correct 5 ms 632 KB Output is correct
50 Correct 5 ms 632 KB Output is correct
51 Correct 5 ms 632 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 380 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 380 KB Output is correct
9 Correct 2 ms 252 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 380 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 380 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 2 ms 380 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 2 ms 348 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 5 ms 632 KB Output is correct
28 Correct 4 ms 632 KB Output is correct
29 Correct 4 ms 688 KB Output is correct
30 Correct 5 ms 760 KB Output is correct
31 Correct 5 ms 632 KB Output is correct
32 Correct 4 ms 632 KB Output is correct
33 Correct 4 ms 632 KB Output is correct
34 Correct 5 ms 760 KB Output is correct
35 Correct 5 ms 632 KB Output is correct
36 Correct 5 ms 632 KB Output is correct
37 Correct 4 ms 632 KB Output is correct
38 Correct 5 ms 648 KB Output is correct
39 Correct 5 ms 632 KB Output is correct
40 Correct 5 ms 676 KB Output is correct
41 Correct 4 ms 632 KB Output is correct
42 Correct 4 ms 632 KB Output is correct
43 Correct 5 ms 632 KB Output is correct
44 Correct 5 ms 676 KB Output is correct
45 Correct 5 ms 632 KB Output is correct
46 Correct 5 ms 632 KB Output is correct
47 Correct 4 ms 676 KB Output is correct
48 Correct 5 ms 632 KB Output is correct
49 Correct 5 ms 632 KB Output is correct
50 Correct 5 ms 632 KB Output is correct
51 Correct 5 ms 632 KB Output is correct
52 Correct 256 ms 20284 KB Output is correct
53 Correct 258 ms 24860 KB Output is correct
54 Correct 255 ms 24800 KB Output is correct
55 Correct 264 ms 24860 KB Output is correct
56 Correct 412 ms 24792 KB Output is correct
57 Correct 260 ms 24744 KB Output is correct
58 Correct 260 ms 24660 KB Output is correct
59 Correct 260 ms 24796 KB Output is correct
60 Correct 255 ms 24788 KB Output is correct
61 Correct 260 ms 24664 KB Output is correct
62 Correct 262 ms 24784 KB Output is correct
63 Correct 259 ms 24660 KB Output is correct
64 Correct 260 ms 24748 KB Output is correct
65 Correct 261 ms 24788 KB Output is correct
66 Correct 261 ms 24928 KB Output is correct
67 Correct 260 ms 24944 KB Output is correct
68 Correct 261 ms 24792 KB Output is correct