#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
map<int,int> mp;
int n; cin >> n;
for(int i = 1 ; i <= n ; ++i) {
int a; cin >> a;
int b; cin >> b;
mp[a] += b;
}
int sum = 0;
int Min = 0;
int ans = 0;
for(auto it : mp) {
Min = min(Min,sum - it.first); sum += it.second;
ans = max(ans,sum - it.first - Min);
}
cout << ans << endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 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 |
12 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
248 KB |
Output is correct |
8 |
Correct |
2 ms |
348 KB |
Output is correct |
9 |
Correct |
2 ms |
376 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 |
376 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 |
12 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
248 KB |
Output is correct |
8 |
Correct |
2 ms |
348 KB |
Output is correct |
9 |
Correct |
2 ms |
376 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 |
376 KB |
Output is correct |
13 |
Correct |
2 ms |
376 KB |
Output is correct |
14 |
Correct |
2 ms |
380 KB |
Output is correct |
15 |
Correct |
2 ms |
380 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 |
376 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 |
376 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 |
376 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 |
376 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 |
12 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
248 KB |
Output is correct |
8 |
Correct |
2 ms |
348 KB |
Output is correct |
9 |
Correct |
2 ms |
376 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 |
376 KB |
Output is correct |
13 |
Correct |
2 ms |
376 KB |
Output is correct |
14 |
Correct |
2 ms |
380 KB |
Output is correct |
15 |
Correct |
2 ms |
380 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 |
376 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 |
376 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 |
376 KB |
Output is correct |
26 |
Correct |
2 ms |
376 KB |
Output is correct |
27 |
Correct |
6 ms |
760 KB |
Output is correct |
28 |
Correct |
6 ms |
760 KB |
Output is correct |
29 |
Correct |
6 ms |
760 KB |
Output is correct |
30 |
Correct |
6 ms |
764 KB |
Output is correct |
31 |
Correct |
6 ms |
760 KB |
Output is correct |
32 |
Correct |
6 ms |
760 KB |
Output is correct |
33 |
Correct |
6 ms |
760 KB |
Output is correct |
34 |
Correct |
5 ms |
760 KB |
Output is correct |
35 |
Correct |
6 ms |
760 KB |
Output is correct |
36 |
Correct |
6 ms |
804 KB |
Output is correct |
37 |
Correct |
6 ms |
732 KB |
Output is correct |
38 |
Correct |
6 ms |
760 KB |
Output is correct |
39 |
Correct |
6 ms |
760 KB |
Output is correct |
40 |
Correct |
5 ms |
760 KB |
Output is correct |
41 |
Correct |
7 ms |
760 KB |
Output is correct |
42 |
Correct |
6 ms |
760 KB |
Output is correct |
43 |
Correct |
6 ms |
760 KB |
Output is correct |
44 |
Correct |
6 ms |
760 KB |
Output is correct |
45 |
Correct |
6 ms |
760 KB |
Output is correct |
46 |
Correct |
6 ms |
764 KB |
Output is correct |
47 |
Correct |
7 ms |
760 KB |
Output is correct |
48 |
Correct |
6 ms |
812 KB |
Output is correct |
49 |
Correct |
6 ms |
760 KB |
Output is correct |
50 |
Correct |
6 ms |
764 KB |
Output is correct |
51 |
Correct |
6 ms |
760 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 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 |
12 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
248 KB |
Output is correct |
8 |
Correct |
2 ms |
348 KB |
Output is correct |
9 |
Correct |
2 ms |
376 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 |
376 KB |
Output is correct |
13 |
Correct |
2 ms |
376 KB |
Output is correct |
14 |
Correct |
2 ms |
380 KB |
Output is correct |
15 |
Correct |
2 ms |
380 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 |
376 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 |
376 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 |
376 KB |
Output is correct |
26 |
Correct |
2 ms |
376 KB |
Output is correct |
27 |
Correct |
6 ms |
760 KB |
Output is correct |
28 |
Correct |
6 ms |
760 KB |
Output is correct |
29 |
Correct |
6 ms |
760 KB |
Output is correct |
30 |
Correct |
6 ms |
764 KB |
Output is correct |
31 |
Correct |
6 ms |
760 KB |
Output is correct |
32 |
Correct |
6 ms |
760 KB |
Output is correct |
33 |
Correct |
6 ms |
760 KB |
Output is correct |
34 |
Correct |
5 ms |
760 KB |
Output is correct |
35 |
Correct |
6 ms |
760 KB |
Output is correct |
36 |
Correct |
6 ms |
804 KB |
Output is correct |
37 |
Correct |
6 ms |
732 KB |
Output is correct |
38 |
Correct |
6 ms |
760 KB |
Output is correct |
39 |
Correct |
6 ms |
760 KB |
Output is correct |
40 |
Correct |
5 ms |
760 KB |
Output is correct |
41 |
Correct |
7 ms |
760 KB |
Output is correct |
42 |
Correct |
6 ms |
760 KB |
Output is correct |
43 |
Correct |
6 ms |
760 KB |
Output is correct |
44 |
Correct |
6 ms |
760 KB |
Output is correct |
45 |
Correct |
6 ms |
760 KB |
Output is correct |
46 |
Correct |
6 ms |
764 KB |
Output is correct |
47 |
Correct |
7 ms |
760 KB |
Output is correct |
48 |
Correct |
6 ms |
812 KB |
Output is correct |
49 |
Correct |
6 ms |
760 KB |
Output is correct |
50 |
Correct |
6 ms |
764 KB |
Output is correct |
51 |
Correct |
6 ms |
760 KB |
Output is correct |
52 |
Correct |
818 ms |
44332 KB |
Output is correct |
53 |
Correct |
832 ms |
44408 KB |
Output is correct |
54 |
Correct |
793 ms |
44536 KB |
Output is correct |
55 |
Correct |
816 ms |
44356 KB |
Output is correct |
56 |
Correct |
853 ms |
44316 KB |
Output is correct |
57 |
Correct |
806 ms |
44640 KB |
Output is correct |
58 |
Correct |
808 ms |
44380 KB |
Output is correct |
59 |
Correct |
795 ms |
44412 KB |
Output is correct |
60 |
Correct |
914 ms |
44540 KB |
Output is correct |
61 |
Correct |
808 ms |
44408 KB |
Output is correct |
62 |
Correct |
847 ms |
44448 KB |
Output is correct |
63 |
Correct |
800 ms |
44408 KB |
Output is correct |
64 |
Correct |
813 ms |
44484 KB |
Output is correct |
65 |
Correct |
815 ms |
44364 KB |
Output is correct |
66 |
Correct |
762 ms |
44520 KB |
Output is correct |
67 |
Correct |
797 ms |
44364 KB |
Output is correct |
68 |
Correct |
786 ms |
44492 KB |
Output is correct |