Submission #224139

# Submission time Handle Problem Language Result Execution time Memory
224139 2020-04-17T08:47:09 Z bharat2002 Art Exhibition (JOI18_art) C++14
100 / 100
779 ms 44540 KB
/*input
3
100 3
200 4
300 5
*/
#include<bits/stdc++.h>
using namespace std;
const int N=5e5 + 100;
const int mod=1e9 + 7;
#define int long long
const int inf=1e18;
#define pii pair<int, int>
#define f first
#define s second 
#define mp make_pair
#define FOR(i, n) for(int i=1;i<=n;i++)
#define TRACE(x) cerr << #x << " = " << x << endl 
//Trace prints the name of the variable and the value.
int n;map<int, int> vals;int pref[N];
bool sf(pii a, pii b)
{
	return a.f<b.f;
}
signed main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		int a, b;cin>>a>>b;vals[a]+=b;
	}
	int sum=0;int mval=0, ans=0;
	for(auto i:vals)
	{
		sum+=i.s;ans=max(ans, i.s);
		mval=max(mval, i.f - sum + i.s);
		ans=max(ans, sum + mval - i.f);
		
	}
	cout<<ans;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 436 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 436 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 5 ms 512 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
21 Correct 5 ms 384 KB Output is correct
22 Correct 5 ms 384 KB Output is correct
23 Correct 5 ms 384 KB Output is correct
24 Correct 5 ms 384 KB Output is correct
25 Correct 5 ms 384 KB Output is correct
26 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 436 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 5 ms 512 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
21 Correct 5 ms 384 KB Output is correct
22 Correct 5 ms 384 KB Output is correct
23 Correct 5 ms 384 KB Output is correct
24 Correct 5 ms 384 KB Output is correct
25 Correct 5 ms 384 KB Output is correct
26 Correct 5 ms 384 KB Output is correct
27 Correct 8 ms 768 KB Output is correct
28 Correct 8 ms 768 KB Output is correct
29 Correct 9 ms 768 KB Output is correct
30 Correct 9 ms 792 KB Output is correct
31 Correct 8 ms 768 KB Output is correct
32 Correct 8 ms 768 KB Output is correct
33 Correct 8 ms 768 KB Output is correct
34 Correct 8 ms 768 KB Output is correct
35 Correct 8 ms 768 KB Output is correct
36 Correct 8 ms 768 KB Output is correct
37 Correct 8 ms 816 KB Output is correct
38 Correct 9 ms 768 KB Output is correct
39 Correct 8 ms 768 KB Output is correct
40 Correct 8 ms 768 KB Output is correct
41 Correct 8 ms 768 KB Output is correct
42 Correct 8 ms 768 KB Output is correct
43 Correct 8 ms 768 KB Output is correct
44 Correct 8 ms 768 KB Output is correct
45 Correct 7 ms 768 KB Output is correct
46 Correct 8 ms 768 KB Output is correct
47 Correct 8 ms 768 KB Output is correct
48 Correct 7 ms 768 KB Output is correct
49 Correct 7 ms 768 KB Output is correct
50 Correct 8 ms 768 KB Output is correct
51 Correct 7 ms 768 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 436 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 5 ms 512 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
21 Correct 5 ms 384 KB Output is correct
22 Correct 5 ms 384 KB Output is correct
23 Correct 5 ms 384 KB Output is correct
24 Correct 5 ms 384 KB Output is correct
25 Correct 5 ms 384 KB Output is correct
26 Correct 5 ms 384 KB Output is correct
27 Correct 8 ms 768 KB Output is correct
28 Correct 8 ms 768 KB Output is correct
29 Correct 9 ms 768 KB Output is correct
30 Correct 9 ms 792 KB Output is correct
31 Correct 8 ms 768 KB Output is correct
32 Correct 8 ms 768 KB Output is correct
33 Correct 8 ms 768 KB Output is correct
34 Correct 8 ms 768 KB Output is correct
35 Correct 8 ms 768 KB Output is correct
36 Correct 8 ms 768 KB Output is correct
37 Correct 8 ms 816 KB Output is correct
38 Correct 9 ms 768 KB Output is correct
39 Correct 8 ms 768 KB Output is correct
40 Correct 8 ms 768 KB Output is correct
41 Correct 8 ms 768 KB Output is correct
42 Correct 8 ms 768 KB Output is correct
43 Correct 8 ms 768 KB Output is correct
44 Correct 8 ms 768 KB Output is correct
45 Correct 7 ms 768 KB Output is correct
46 Correct 8 ms 768 KB Output is correct
47 Correct 8 ms 768 KB Output is correct
48 Correct 7 ms 768 KB Output is correct
49 Correct 7 ms 768 KB Output is correct
50 Correct 8 ms 768 KB Output is correct
51 Correct 7 ms 768 KB Output is correct
52 Correct 740 ms 44320 KB Output is correct
53 Correct 729 ms 44324 KB Output is correct
54 Correct 715 ms 44392 KB Output is correct
55 Correct 725 ms 44280 KB Output is correct
56 Correct 779 ms 44424 KB Output is correct
57 Correct 722 ms 44512 KB Output is correct
58 Correct 701 ms 44336 KB Output is correct
59 Correct 698 ms 44272 KB Output is correct
60 Correct 710 ms 44420 KB Output is correct
61 Correct 698 ms 44272 KB Output is correct
62 Correct 699 ms 44284 KB Output is correct
63 Correct 727 ms 44460 KB Output is correct
64 Correct 672 ms 44280 KB Output is correct
65 Correct 639 ms 44408 KB Output is correct
66 Correct 636 ms 44384 KB Output is correct
67 Correct 660 ms 44540 KB Output is correct
68 Correct 662 ms 44408 KB Output is correct