#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
const int maxn = 500100;
map<ll, ll> sum;
vector<pair<ll, ll> > values;
vector<ll> pref;
ll n, x, y;
ll get_val(int l, int r) {
ll sum =1LL* pref[r] - pref[l-1];
ll diff = values[r].first - values[l].first;
return sum - diff;
}
int main() {
cin>>n;
for(int i=0;i<n;i++) {
cin>>x>>y;
sum[x] += y;
}
values.pb(mp(0LL,0LL));
pref.pb(0LL);
for(auto i:sum) {
values.pb(mp(i.first, i.second));
pref.pb(pref.back() + i.second);
}
ll l = 1LL;
ll result = 0LL;
for(ll i=1;i<values.size();i++) {
for(ll j=1;j<=i;j++) {
result = max(result, get_val(j, i));
}
}
cout<<result;
return 0;
}
Compilation message
art.cpp: In function 'int main()':
art.cpp:34:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(ll i=1;i<values.size();i++) {
~^~~~~~~~~~~~~~
art.cpp:32:8: warning: unused variable 'l' [-Wunused-variable]
ll l = 1LL;
^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
380 KB |
Output is correct |
2 |
Correct |
2 ms |
480 KB |
Output is correct |
3 |
Correct |
2 ms |
480 KB |
Output is correct |
4 |
Correct |
3 ms |
480 KB |
Output is correct |
5 |
Correct |
2 ms |
480 KB |
Output is correct |
6 |
Correct |
3 ms |
480 KB |
Output is correct |
7 |
Correct |
2 ms |
580 KB |
Output is correct |
8 |
Correct |
3 ms |
580 KB |
Output is correct |
9 |
Correct |
2 ms |
660 KB |
Output is correct |
10 |
Correct |
3 ms |
660 KB |
Output is correct |
11 |
Correct |
3 ms |
660 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
380 KB |
Output is correct |
2 |
Correct |
2 ms |
480 KB |
Output is correct |
3 |
Correct |
2 ms |
480 KB |
Output is correct |
4 |
Correct |
3 ms |
480 KB |
Output is correct |
5 |
Correct |
2 ms |
480 KB |
Output is correct |
6 |
Correct |
3 ms |
480 KB |
Output is correct |
7 |
Correct |
2 ms |
580 KB |
Output is correct |
8 |
Correct |
3 ms |
580 KB |
Output is correct |
9 |
Correct |
2 ms |
660 KB |
Output is correct |
10 |
Correct |
3 ms |
660 KB |
Output is correct |
11 |
Correct |
3 ms |
660 KB |
Output is correct |
12 |
Correct |
4 ms |
660 KB |
Output is correct |
13 |
Correct |
4 ms |
660 KB |
Output is correct |
14 |
Correct |
4 ms |
660 KB |
Output is correct |
15 |
Correct |
4 ms |
676 KB |
Output is correct |
16 |
Correct |
4 ms |
680 KB |
Output is correct |
17 |
Correct |
3 ms |
692 KB |
Output is correct |
18 |
Correct |
4 ms |
716 KB |
Output is correct |
19 |
Correct |
3 ms |
724 KB |
Output is correct |
20 |
Correct |
4 ms |
736 KB |
Output is correct |
21 |
Correct |
5 ms |
744 KB |
Output is correct |
22 |
Correct |
5 ms |
752 KB |
Output is correct |
23 |
Correct |
5 ms |
760 KB |
Output is correct |
24 |
Correct |
3 ms |
768 KB |
Output is correct |
25 |
Correct |
3 ms |
776 KB |
Output is correct |
26 |
Correct |
4 ms |
784 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
380 KB |
Output is correct |
2 |
Correct |
2 ms |
480 KB |
Output is correct |
3 |
Correct |
2 ms |
480 KB |
Output is correct |
4 |
Correct |
3 ms |
480 KB |
Output is correct |
5 |
Correct |
2 ms |
480 KB |
Output is correct |
6 |
Correct |
3 ms |
480 KB |
Output is correct |
7 |
Correct |
2 ms |
580 KB |
Output is correct |
8 |
Correct |
3 ms |
580 KB |
Output is correct |
9 |
Correct |
2 ms |
660 KB |
Output is correct |
10 |
Correct |
3 ms |
660 KB |
Output is correct |
11 |
Correct |
3 ms |
660 KB |
Output is correct |
12 |
Correct |
4 ms |
660 KB |
Output is correct |
13 |
Correct |
4 ms |
660 KB |
Output is correct |
14 |
Correct |
4 ms |
660 KB |
Output is correct |
15 |
Correct |
4 ms |
676 KB |
Output is correct |
16 |
Correct |
4 ms |
680 KB |
Output is correct |
17 |
Correct |
3 ms |
692 KB |
Output is correct |
18 |
Correct |
4 ms |
716 KB |
Output is correct |
19 |
Correct |
3 ms |
724 KB |
Output is correct |
20 |
Correct |
4 ms |
736 KB |
Output is correct |
21 |
Correct |
5 ms |
744 KB |
Output is correct |
22 |
Correct |
5 ms |
752 KB |
Output is correct |
23 |
Correct |
5 ms |
760 KB |
Output is correct |
24 |
Correct |
3 ms |
768 KB |
Output is correct |
25 |
Correct |
3 ms |
776 KB |
Output is correct |
26 |
Correct |
4 ms |
784 KB |
Output is correct |
27 |
Correct |
38 ms |
1432 KB |
Output is correct |
28 |
Correct |
31 ms |
1560 KB |
Output is correct |
29 |
Correct |
36 ms |
1600 KB |
Output is correct |
30 |
Correct |
33 ms |
1816 KB |
Output is correct |
31 |
Correct |
36 ms |
2064 KB |
Output is correct |
32 |
Correct |
43 ms |
2064 KB |
Output is correct |
33 |
Correct |
36 ms |
2108 KB |
Output is correct |
34 |
Correct |
39 ms |
2332 KB |
Output is correct |
35 |
Correct |
40 ms |
2396 KB |
Output is correct |
36 |
Correct |
43 ms |
2584 KB |
Output is correct |
37 |
Correct |
34 ms |
2712 KB |
Output is correct |
38 |
Correct |
35 ms |
2716 KB |
Output is correct |
39 |
Correct |
36 ms |
2968 KB |
Output is correct |
40 |
Correct |
34 ms |
3220 KB |
Output is correct |
41 |
Correct |
39 ms |
3220 KB |
Output is correct |
42 |
Correct |
41 ms |
3348 KB |
Output is correct |
43 |
Correct |
31 ms |
3384 KB |
Output is correct |
44 |
Correct |
36 ms |
3668 KB |
Output is correct |
45 |
Correct |
52 ms |
3732 KB |
Output is correct |
46 |
Correct |
36 ms |
3768 KB |
Output is correct |
47 |
Correct |
35 ms |
3928 KB |
Output is correct |
48 |
Correct |
33 ms |
4148 KB |
Output is correct |
49 |
Correct |
46 ms |
4268 KB |
Output is correct |
50 |
Correct |
39 ms |
4432 KB |
Output is correct |
51 |
Correct |
36 ms |
4488 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
380 KB |
Output is correct |
2 |
Correct |
2 ms |
480 KB |
Output is correct |
3 |
Correct |
2 ms |
480 KB |
Output is correct |
4 |
Correct |
3 ms |
480 KB |
Output is correct |
5 |
Correct |
2 ms |
480 KB |
Output is correct |
6 |
Correct |
3 ms |
480 KB |
Output is correct |
7 |
Correct |
2 ms |
580 KB |
Output is correct |
8 |
Correct |
3 ms |
580 KB |
Output is correct |
9 |
Correct |
2 ms |
660 KB |
Output is correct |
10 |
Correct |
3 ms |
660 KB |
Output is correct |
11 |
Correct |
3 ms |
660 KB |
Output is correct |
12 |
Correct |
4 ms |
660 KB |
Output is correct |
13 |
Correct |
4 ms |
660 KB |
Output is correct |
14 |
Correct |
4 ms |
660 KB |
Output is correct |
15 |
Correct |
4 ms |
676 KB |
Output is correct |
16 |
Correct |
4 ms |
680 KB |
Output is correct |
17 |
Correct |
3 ms |
692 KB |
Output is correct |
18 |
Correct |
4 ms |
716 KB |
Output is correct |
19 |
Correct |
3 ms |
724 KB |
Output is correct |
20 |
Correct |
4 ms |
736 KB |
Output is correct |
21 |
Correct |
5 ms |
744 KB |
Output is correct |
22 |
Correct |
5 ms |
752 KB |
Output is correct |
23 |
Correct |
5 ms |
760 KB |
Output is correct |
24 |
Correct |
3 ms |
768 KB |
Output is correct |
25 |
Correct |
3 ms |
776 KB |
Output is correct |
26 |
Correct |
4 ms |
784 KB |
Output is correct |
27 |
Correct |
38 ms |
1432 KB |
Output is correct |
28 |
Correct |
31 ms |
1560 KB |
Output is correct |
29 |
Correct |
36 ms |
1600 KB |
Output is correct |
30 |
Correct |
33 ms |
1816 KB |
Output is correct |
31 |
Correct |
36 ms |
2064 KB |
Output is correct |
32 |
Correct |
43 ms |
2064 KB |
Output is correct |
33 |
Correct |
36 ms |
2108 KB |
Output is correct |
34 |
Correct |
39 ms |
2332 KB |
Output is correct |
35 |
Correct |
40 ms |
2396 KB |
Output is correct |
36 |
Correct |
43 ms |
2584 KB |
Output is correct |
37 |
Correct |
34 ms |
2712 KB |
Output is correct |
38 |
Correct |
35 ms |
2716 KB |
Output is correct |
39 |
Correct |
36 ms |
2968 KB |
Output is correct |
40 |
Correct |
34 ms |
3220 KB |
Output is correct |
41 |
Correct |
39 ms |
3220 KB |
Output is correct |
42 |
Correct |
41 ms |
3348 KB |
Output is correct |
43 |
Correct |
31 ms |
3384 KB |
Output is correct |
44 |
Correct |
36 ms |
3668 KB |
Output is correct |
45 |
Correct |
52 ms |
3732 KB |
Output is correct |
46 |
Correct |
36 ms |
3768 KB |
Output is correct |
47 |
Correct |
35 ms |
3928 KB |
Output is correct |
48 |
Correct |
33 ms |
4148 KB |
Output is correct |
49 |
Correct |
46 ms |
4268 KB |
Output is correct |
50 |
Correct |
39 ms |
4432 KB |
Output is correct |
51 |
Correct |
36 ms |
4488 KB |
Output is correct |
52 |
Execution timed out |
1082 ms |
41140 KB |
Time limit exceeded |
53 |
Halted |
0 ms |
0 KB |
- |