//tavakol bar khoda
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int MAXN = (int)1e5 + 7;
const int MOD = (int)1e9 + 7;
const int infint = (int)1e8 + 3;
const ll inf = (ll)1e18;
ll n, part[MAXN];
pair<ll, ll> P[MAXN];
int main()
{
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
cin >> n;
for (int i = 0; i < n; i++)
cin >> P[i].first >> P[i].second;
sort(P, P + n);
part[0] = P[0].second;
for (int i = 1; i < n; i++)
part[i] = part[i - 1] + P[i].second;
ll ans = 0, mn = 0;
for (int i = 0; i < n; i++)
{
if(i == 0)
mn = -P[0].first;
else
mn = min(mn, part[i - 1] - P[i].first);
ans = max(ans, part[i] - P[i].first - mn);
}
cout << ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
512 KB |
Output is correct |
3 |
Correct |
2 ms |
512 KB |
Output is correct |
4 |
Correct |
2 ms |
512 KB |
Output is correct |
5 |
Correct |
3 ms |
512 KB |
Output is correct |
6 |
Correct |
2 ms |
612 KB |
Output is correct |
7 |
Correct |
2 ms |
612 KB |
Output is correct |
8 |
Correct |
2 ms |
620 KB |
Output is correct |
9 |
Correct |
2 ms |
664 KB |
Output is correct |
10 |
Correct |
2 ms |
816 KB |
Output is correct |
11 |
Correct |
2 ms |
816 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
512 KB |
Output is correct |
3 |
Correct |
2 ms |
512 KB |
Output is correct |
4 |
Correct |
2 ms |
512 KB |
Output is correct |
5 |
Correct |
3 ms |
512 KB |
Output is correct |
6 |
Correct |
2 ms |
612 KB |
Output is correct |
7 |
Correct |
2 ms |
612 KB |
Output is correct |
8 |
Correct |
2 ms |
620 KB |
Output is correct |
9 |
Correct |
2 ms |
664 KB |
Output is correct |
10 |
Correct |
2 ms |
816 KB |
Output is correct |
11 |
Correct |
2 ms |
816 KB |
Output is correct |
12 |
Correct |
2 ms |
868 KB |
Output is correct |
13 |
Correct |
2 ms |
896 KB |
Output is correct |
14 |
Correct |
2 ms |
896 KB |
Output is correct |
15 |
Correct |
2 ms |
900 KB |
Output is correct |
16 |
Correct |
2 ms |
924 KB |
Output is correct |
17 |
Correct |
2 ms |
932 KB |
Output is correct |
18 |
Correct |
2 ms |
940 KB |
Output is correct |
19 |
Correct |
2 ms |
972 KB |
Output is correct |
20 |
Correct |
2 ms |
976 KB |
Output is correct |
21 |
Correct |
2 ms |
984 KB |
Output is correct |
22 |
Correct |
2 ms |
1008 KB |
Output is correct |
23 |
Correct |
2 ms |
1016 KB |
Output is correct |
24 |
Correct |
2 ms |
1028 KB |
Output is correct |
25 |
Correct |
2 ms |
1032 KB |
Output is correct |
26 |
Correct |
2 ms |
1040 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
512 KB |
Output is correct |
3 |
Correct |
2 ms |
512 KB |
Output is correct |
4 |
Correct |
2 ms |
512 KB |
Output is correct |
5 |
Correct |
3 ms |
512 KB |
Output is correct |
6 |
Correct |
2 ms |
612 KB |
Output is correct |
7 |
Correct |
2 ms |
612 KB |
Output is correct |
8 |
Correct |
2 ms |
620 KB |
Output is correct |
9 |
Correct |
2 ms |
664 KB |
Output is correct |
10 |
Correct |
2 ms |
816 KB |
Output is correct |
11 |
Correct |
2 ms |
816 KB |
Output is correct |
12 |
Correct |
2 ms |
868 KB |
Output is correct |
13 |
Correct |
2 ms |
896 KB |
Output is correct |
14 |
Correct |
2 ms |
896 KB |
Output is correct |
15 |
Correct |
2 ms |
900 KB |
Output is correct |
16 |
Correct |
2 ms |
924 KB |
Output is correct |
17 |
Correct |
2 ms |
932 KB |
Output is correct |
18 |
Correct |
2 ms |
940 KB |
Output is correct |
19 |
Correct |
2 ms |
972 KB |
Output is correct |
20 |
Correct |
2 ms |
976 KB |
Output is correct |
21 |
Correct |
2 ms |
984 KB |
Output is correct |
22 |
Correct |
2 ms |
1008 KB |
Output is correct |
23 |
Correct |
2 ms |
1016 KB |
Output is correct |
24 |
Correct |
2 ms |
1028 KB |
Output is correct |
25 |
Correct |
2 ms |
1032 KB |
Output is correct |
26 |
Correct |
2 ms |
1040 KB |
Output is correct |
27 |
Correct |
4 ms |
1304 KB |
Output is correct |
28 |
Correct |
4 ms |
1432 KB |
Output is correct |
29 |
Correct |
3 ms |
1560 KB |
Output is correct |
30 |
Correct |
3 ms |
1688 KB |
Output is correct |
31 |
Correct |
4 ms |
1816 KB |
Output is correct |
32 |
Correct |
4 ms |
1944 KB |
Output is correct |
33 |
Correct |
3 ms |
2072 KB |
Output is correct |
34 |
Correct |
4 ms |
2200 KB |
Output is correct |
35 |
Correct |
4 ms |
2328 KB |
Output is correct |
36 |
Correct |
4 ms |
2568 KB |
Output is correct |
37 |
Correct |
4 ms |
2584 KB |
Output is correct |
38 |
Correct |
4 ms |
2712 KB |
Output is correct |
39 |
Correct |
4 ms |
2840 KB |
Output is correct |
40 |
Correct |
4 ms |
2968 KB |
Output is correct |
41 |
Correct |
4 ms |
3096 KB |
Output is correct |
42 |
Correct |
4 ms |
3220 KB |
Output is correct |
43 |
Correct |
4 ms |
3348 KB |
Output is correct |
44 |
Correct |
4 ms |
3476 KB |
Output is correct |
45 |
Correct |
4 ms |
3604 KB |
Output is correct |
46 |
Correct |
4 ms |
3732 KB |
Output is correct |
47 |
Correct |
3 ms |
3860 KB |
Output is correct |
48 |
Correct |
4 ms |
3992 KB |
Output is correct |
49 |
Correct |
4 ms |
4116 KB |
Output is correct |
50 |
Correct |
4 ms |
4244 KB |
Output is correct |
51 |
Correct |
4 ms |
4372 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
512 KB |
Output is correct |
3 |
Correct |
2 ms |
512 KB |
Output is correct |
4 |
Correct |
2 ms |
512 KB |
Output is correct |
5 |
Correct |
3 ms |
512 KB |
Output is correct |
6 |
Correct |
2 ms |
612 KB |
Output is correct |
7 |
Correct |
2 ms |
612 KB |
Output is correct |
8 |
Correct |
2 ms |
620 KB |
Output is correct |
9 |
Correct |
2 ms |
664 KB |
Output is correct |
10 |
Correct |
2 ms |
816 KB |
Output is correct |
11 |
Correct |
2 ms |
816 KB |
Output is correct |
12 |
Correct |
2 ms |
868 KB |
Output is correct |
13 |
Correct |
2 ms |
896 KB |
Output is correct |
14 |
Correct |
2 ms |
896 KB |
Output is correct |
15 |
Correct |
2 ms |
900 KB |
Output is correct |
16 |
Correct |
2 ms |
924 KB |
Output is correct |
17 |
Correct |
2 ms |
932 KB |
Output is correct |
18 |
Correct |
2 ms |
940 KB |
Output is correct |
19 |
Correct |
2 ms |
972 KB |
Output is correct |
20 |
Correct |
2 ms |
976 KB |
Output is correct |
21 |
Correct |
2 ms |
984 KB |
Output is correct |
22 |
Correct |
2 ms |
1008 KB |
Output is correct |
23 |
Correct |
2 ms |
1016 KB |
Output is correct |
24 |
Correct |
2 ms |
1028 KB |
Output is correct |
25 |
Correct |
2 ms |
1032 KB |
Output is correct |
26 |
Correct |
2 ms |
1040 KB |
Output is correct |
27 |
Correct |
4 ms |
1304 KB |
Output is correct |
28 |
Correct |
4 ms |
1432 KB |
Output is correct |
29 |
Correct |
3 ms |
1560 KB |
Output is correct |
30 |
Correct |
3 ms |
1688 KB |
Output is correct |
31 |
Correct |
4 ms |
1816 KB |
Output is correct |
32 |
Correct |
4 ms |
1944 KB |
Output is correct |
33 |
Correct |
3 ms |
2072 KB |
Output is correct |
34 |
Correct |
4 ms |
2200 KB |
Output is correct |
35 |
Correct |
4 ms |
2328 KB |
Output is correct |
36 |
Correct |
4 ms |
2568 KB |
Output is correct |
37 |
Correct |
4 ms |
2584 KB |
Output is correct |
38 |
Correct |
4 ms |
2712 KB |
Output is correct |
39 |
Correct |
4 ms |
2840 KB |
Output is correct |
40 |
Correct |
4 ms |
2968 KB |
Output is correct |
41 |
Correct |
4 ms |
3096 KB |
Output is correct |
42 |
Correct |
4 ms |
3220 KB |
Output is correct |
43 |
Correct |
4 ms |
3348 KB |
Output is correct |
44 |
Correct |
4 ms |
3476 KB |
Output is correct |
45 |
Correct |
4 ms |
3604 KB |
Output is correct |
46 |
Correct |
4 ms |
3732 KB |
Output is correct |
47 |
Correct |
3 ms |
3860 KB |
Output is correct |
48 |
Correct |
4 ms |
3992 KB |
Output is correct |
49 |
Correct |
4 ms |
4116 KB |
Output is correct |
50 |
Correct |
4 ms |
4244 KB |
Output is correct |
51 |
Correct |
4 ms |
4372 KB |
Output is correct |
52 |
Runtime error |
48 ms |
12952 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
53 |
Halted |
0 ms |
0 KB |
- |