#include "bits/stdc++.h"
using namespace std;
#define fi first
#define se second
#define ll long long
#define dbg(v) cerr<<#v<<" = "<<v<<'\n'
#define vi vector<int>
#define vl vector <ll>
#define pii pair<int,int>
#define mp make_pair
#define db long double
#define pb push_back
#define all(s) s.begin(),s.end()
template < class T > T smin(T &a,T b) {if (a > b) a = b;return a;}
template < class T > T smax(T &a,T b) {if (a < b) a = b;return a;}
int main(void) {
int n;
cin>>n;
map < ll , ll > M;
for (int i = 0;i < n;++i) {
ll u,v;
cin>>u>>v;
M[u] += v;
}
vector < pair < ll , ll > > s;
for (auto it : M)
s.pb(it);
n = s.size();
vl ss;
for (int i = 1;i < n;++i)
s[i].se += s[i - 1].se;
ll mn = -s[0].fi;
ll ans = 0;
for (int i = 1;i < n;++i) {
if (i > 0)
smin(mn,s[i - 1].se - s[i].fi);
smax(ans,s[i].se - s[i].fi - mn);
}
cout << ans << '\n';
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
380 KB |
Output is correct |
2 |
Correct |
2 ms |
380 KB |
Output is correct |
3 |
Correct |
2 ms |
380 KB |
Output is correct |
4 |
Correct |
2 ms |
440 KB |
Output is correct |
5 |
Correct |
2 ms |
532 KB |
Output is correct |
6 |
Correct |
2 ms |
652 KB |
Output is correct |
7 |
Correct |
2 ms |
712 KB |
Output is correct |
8 |
Correct |
2 ms |
720 KB |
Output is correct |
9 |
Correct |
2 ms |
728 KB |
Output is correct |
10 |
Correct |
2 ms |
728 KB |
Output is correct |
11 |
Correct |
2 ms |
728 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
380 KB |
Output is correct |
2 |
Correct |
2 ms |
380 KB |
Output is correct |
3 |
Correct |
2 ms |
380 KB |
Output is correct |
4 |
Correct |
2 ms |
440 KB |
Output is correct |
5 |
Correct |
2 ms |
532 KB |
Output is correct |
6 |
Correct |
2 ms |
652 KB |
Output is correct |
7 |
Correct |
2 ms |
712 KB |
Output is correct |
8 |
Correct |
2 ms |
720 KB |
Output is correct |
9 |
Correct |
2 ms |
728 KB |
Output is correct |
10 |
Correct |
2 ms |
728 KB |
Output is correct |
11 |
Correct |
2 ms |
728 KB |
Output is correct |
12 |
Correct |
2 ms |
772 KB |
Output is correct |
13 |
Correct |
3 ms |
780 KB |
Output is correct |
14 |
Correct |
3 ms |
808 KB |
Output is correct |
15 |
Correct |
2 ms |
836 KB |
Output is correct |
16 |
Correct |
3 ms |
856 KB |
Output is correct |
17 |
Correct |
2 ms |
880 KB |
Output is correct |
18 |
Correct |
2 ms |
888 KB |
Output is correct |
19 |
Correct |
2 ms |
888 KB |
Output is correct |
20 |
Correct |
3 ms |
888 KB |
Output is correct |
21 |
Correct |
2 ms |
912 KB |
Output is correct |
22 |
Correct |
3 ms |
920 KB |
Output is correct |
23 |
Correct |
2 ms |
1024 KB |
Output is correct |
24 |
Correct |
2 ms |
1024 KB |
Output is correct |
25 |
Correct |
2 ms |
1024 KB |
Output is correct |
26 |
Correct |
3 ms |
1024 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
380 KB |
Output is correct |
2 |
Correct |
2 ms |
380 KB |
Output is correct |
3 |
Correct |
2 ms |
380 KB |
Output is correct |
4 |
Correct |
2 ms |
440 KB |
Output is correct |
5 |
Correct |
2 ms |
532 KB |
Output is correct |
6 |
Correct |
2 ms |
652 KB |
Output is correct |
7 |
Correct |
2 ms |
712 KB |
Output is correct |
8 |
Correct |
2 ms |
720 KB |
Output is correct |
9 |
Correct |
2 ms |
728 KB |
Output is correct |
10 |
Correct |
2 ms |
728 KB |
Output is correct |
11 |
Correct |
2 ms |
728 KB |
Output is correct |
12 |
Correct |
2 ms |
772 KB |
Output is correct |
13 |
Correct |
3 ms |
780 KB |
Output is correct |
14 |
Correct |
3 ms |
808 KB |
Output is correct |
15 |
Correct |
2 ms |
836 KB |
Output is correct |
16 |
Correct |
3 ms |
856 KB |
Output is correct |
17 |
Correct |
2 ms |
880 KB |
Output is correct |
18 |
Correct |
2 ms |
888 KB |
Output is correct |
19 |
Correct |
2 ms |
888 KB |
Output is correct |
20 |
Correct |
3 ms |
888 KB |
Output is correct |
21 |
Correct |
2 ms |
912 KB |
Output is correct |
22 |
Correct |
3 ms |
920 KB |
Output is correct |
23 |
Correct |
2 ms |
1024 KB |
Output is correct |
24 |
Correct |
2 ms |
1024 KB |
Output is correct |
25 |
Correct |
2 ms |
1024 KB |
Output is correct |
26 |
Correct |
3 ms |
1024 KB |
Output is correct |
27 |
Correct |
10 ms |
1500 KB |
Output is correct |
28 |
Correct |
10 ms |
1728 KB |
Output is correct |
29 |
Correct |
11 ms |
1848 KB |
Output is correct |
30 |
Correct |
10 ms |
1984 KB |
Output is correct |
31 |
Correct |
10 ms |
2020 KB |
Output is correct |
32 |
Correct |
11 ms |
2236 KB |
Output is correct |
33 |
Correct |
11 ms |
2352 KB |
Output is correct |
34 |
Correct |
10 ms |
2464 KB |
Output is correct |
35 |
Correct |
11 ms |
2532 KB |
Output is correct |
36 |
Correct |
16 ms |
2788 KB |
Output is correct |
37 |
Correct |
10 ms |
3008 KB |
Output is correct |
38 |
Correct |
11 ms |
3008 KB |
Output is correct |
39 |
Correct |
10 ms |
3172 KB |
Output is correct |
40 |
Correct |
10 ms |
3300 KB |
Output is correct |
41 |
Correct |
10 ms |
3420 KB |
Output is correct |
42 |
Correct |
12 ms |
3552 KB |
Output is correct |
43 |
Correct |
10 ms |
3592 KB |
Output is correct |
44 |
Correct |
10 ms |
3808 KB |
Output is correct |
45 |
Correct |
10 ms |
3936 KB |
Output is correct |
46 |
Correct |
10 ms |
3972 KB |
Output is correct |
47 |
Correct |
10 ms |
4192 KB |
Output is correct |
48 |
Correct |
10 ms |
4228 KB |
Output is correct |
49 |
Correct |
10 ms |
4356 KB |
Output is correct |
50 |
Correct |
10 ms |
4700 KB |
Output is correct |
51 |
Correct |
10 ms |
4828 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
380 KB |
Output is correct |
2 |
Correct |
2 ms |
380 KB |
Output is correct |
3 |
Correct |
2 ms |
380 KB |
Output is correct |
4 |
Correct |
2 ms |
440 KB |
Output is correct |
5 |
Correct |
2 ms |
532 KB |
Output is correct |
6 |
Correct |
2 ms |
652 KB |
Output is correct |
7 |
Correct |
2 ms |
712 KB |
Output is correct |
8 |
Correct |
2 ms |
720 KB |
Output is correct |
9 |
Correct |
2 ms |
728 KB |
Output is correct |
10 |
Correct |
2 ms |
728 KB |
Output is correct |
11 |
Correct |
2 ms |
728 KB |
Output is correct |
12 |
Correct |
2 ms |
772 KB |
Output is correct |
13 |
Correct |
3 ms |
780 KB |
Output is correct |
14 |
Correct |
3 ms |
808 KB |
Output is correct |
15 |
Correct |
2 ms |
836 KB |
Output is correct |
16 |
Correct |
3 ms |
856 KB |
Output is correct |
17 |
Correct |
2 ms |
880 KB |
Output is correct |
18 |
Correct |
2 ms |
888 KB |
Output is correct |
19 |
Correct |
2 ms |
888 KB |
Output is correct |
20 |
Correct |
3 ms |
888 KB |
Output is correct |
21 |
Correct |
2 ms |
912 KB |
Output is correct |
22 |
Correct |
3 ms |
920 KB |
Output is correct |
23 |
Correct |
2 ms |
1024 KB |
Output is correct |
24 |
Correct |
2 ms |
1024 KB |
Output is correct |
25 |
Correct |
2 ms |
1024 KB |
Output is correct |
26 |
Correct |
3 ms |
1024 KB |
Output is correct |
27 |
Correct |
10 ms |
1500 KB |
Output is correct |
28 |
Correct |
10 ms |
1728 KB |
Output is correct |
29 |
Correct |
11 ms |
1848 KB |
Output is correct |
30 |
Correct |
10 ms |
1984 KB |
Output is correct |
31 |
Correct |
10 ms |
2020 KB |
Output is correct |
32 |
Correct |
11 ms |
2236 KB |
Output is correct |
33 |
Correct |
11 ms |
2352 KB |
Output is correct |
34 |
Correct |
10 ms |
2464 KB |
Output is correct |
35 |
Correct |
11 ms |
2532 KB |
Output is correct |
36 |
Correct |
16 ms |
2788 KB |
Output is correct |
37 |
Correct |
10 ms |
3008 KB |
Output is correct |
38 |
Correct |
11 ms |
3008 KB |
Output is correct |
39 |
Correct |
10 ms |
3172 KB |
Output is correct |
40 |
Correct |
10 ms |
3300 KB |
Output is correct |
41 |
Correct |
10 ms |
3420 KB |
Output is correct |
42 |
Correct |
12 ms |
3552 KB |
Output is correct |
43 |
Correct |
10 ms |
3592 KB |
Output is correct |
44 |
Correct |
10 ms |
3808 KB |
Output is correct |
45 |
Correct |
10 ms |
3936 KB |
Output is correct |
46 |
Correct |
10 ms |
3972 KB |
Output is correct |
47 |
Correct |
10 ms |
4192 KB |
Output is correct |
48 |
Correct |
10 ms |
4228 KB |
Output is correct |
49 |
Correct |
10 ms |
4356 KB |
Output is correct |
50 |
Correct |
10 ms |
4700 KB |
Output is correct |
51 |
Correct |
10 ms |
4828 KB |
Output is correct |
52 |
Execution timed out |
1064 ms |
43584 KB |
Time limit exceeded |
53 |
Halted |
0 ms |
0 KB |
- |