Submission #922760

# Submission time Handle Problem Language Result Execution time Memory
922760 2024-02-06T05:56:55 Z ArgoCahaya Art Exhibition (JOI18_art) C++14
100 / 100
563 ms 44644 KB
#include<bits/stdc++.h>
#define ll long long
#define endl "\n"
#define fi first
#define se second
#define pb push_back
#define pll pair<long long, long long>
#define loop(i,n) for(int i=1;i<=n;i++)
#define loop0(i,n) for(int i=0;i<n;i++)
using namespace std;

//pbds template
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;

//template <class T>
//using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

void solve(){
	ll n;
	cin >> n;
	map<ll,ll> mp;
	for(int i=1;i<=n;i++){
		ll a,b;
		cin >> a >> b;
		mp[a] += b;
	}
	ll ans = 0;
	ll prev = -1;
	ll temp = 0;
	for(auto i:mp){
		ll selisih = i.fi-prev;
//		cout << temp << ' ' << selisih << endl;
		if(temp<selisih){
			temp = 0;
		}
		else{
			temp -= selisih;
		}
//		cout << i.fi << ' ' << temp << ' ' << selisih << ' ' << i.se << ' ' << ans << endl;
		ans = max(ans, temp+i.se);
		temp += i.se;
		prev = i.fi;
	}
	cout << ans << endl;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int tc = 1;
//	cin >> tc;
	while(tc--){
	   solve();
	}
}

# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 1 ms 600 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 1 ms 600 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 460 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 412 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 460 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 1 ms 600 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 460 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 412 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 460 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 2 ms 860 KB Output is correct
28 Correct 2 ms 860 KB Output is correct
29 Correct 3 ms 860 KB Output is correct
30 Correct 2 ms 856 KB Output is correct
31 Correct 2 ms 732 KB Output is correct
32 Correct 2 ms 860 KB Output is correct
33 Correct 2 ms 860 KB Output is correct
34 Correct 2 ms 860 KB Output is correct
35 Correct 2 ms 860 KB Output is correct
36 Correct 2 ms 860 KB Output is correct
37 Correct 2 ms 732 KB Output is correct
38 Correct 2 ms 860 KB Output is correct
39 Correct 2 ms 860 KB Output is correct
40 Correct 3 ms 1116 KB Output is correct
41 Correct 2 ms 856 KB Output is correct
42 Correct 2 ms 860 KB Output is correct
43 Correct 3 ms 860 KB Output is correct
44 Correct 2 ms 856 KB Output is correct
45 Correct 2 ms 860 KB Output is correct
46 Correct 2 ms 752 KB Output is correct
47 Correct 2 ms 856 KB Output is correct
48 Correct 2 ms 860 KB Output is correct
49 Correct 2 ms 728 KB Output is correct
50 Correct 2 ms 856 KB Output is correct
51 Correct 2 ms 860 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 1 ms 600 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 460 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 412 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 460 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 2 ms 860 KB Output is correct
28 Correct 2 ms 860 KB Output is correct
29 Correct 3 ms 860 KB Output is correct
30 Correct 2 ms 856 KB Output is correct
31 Correct 2 ms 732 KB Output is correct
32 Correct 2 ms 860 KB Output is correct
33 Correct 2 ms 860 KB Output is correct
34 Correct 2 ms 860 KB Output is correct
35 Correct 2 ms 860 KB Output is correct
36 Correct 2 ms 860 KB Output is correct
37 Correct 2 ms 732 KB Output is correct
38 Correct 2 ms 860 KB Output is correct
39 Correct 2 ms 860 KB Output is correct
40 Correct 3 ms 1116 KB Output is correct
41 Correct 2 ms 856 KB Output is correct
42 Correct 2 ms 860 KB Output is correct
43 Correct 3 ms 860 KB Output is correct
44 Correct 2 ms 856 KB Output is correct
45 Correct 2 ms 860 KB Output is correct
46 Correct 2 ms 752 KB Output is correct
47 Correct 2 ms 856 KB Output is correct
48 Correct 2 ms 860 KB Output is correct
49 Correct 2 ms 728 KB Output is correct
50 Correct 2 ms 856 KB Output is correct
51 Correct 2 ms 860 KB Output is correct
52 Correct 507 ms 44256 KB Output is correct
53 Correct 539 ms 44416 KB Output is correct
54 Correct 563 ms 44444 KB Output is correct
55 Correct 509 ms 44368 KB Output is correct
56 Correct 474 ms 44412 KB Output is correct
57 Correct 503 ms 44644 KB Output is correct
58 Correct 465 ms 44300 KB Output is correct
59 Correct 501 ms 44372 KB Output is correct
60 Correct 548 ms 44420 KB Output is correct
61 Correct 523 ms 44172 KB Output is correct
62 Correct 467 ms 44420 KB Output is correct
63 Correct 474 ms 44412 KB Output is correct
64 Correct 504 ms 44420 KB Output is correct
65 Correct 516 ms 44404 KB Output is correct
66 Correct 528 ms 44372 KB Output is correct
67 Correct 521 ms 44420 KB Output is correct
68 Correct 447 ms 44344 KB Output is correct