#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define clr(a) memset(a, 0, sizeof(a))
#define sz(x) x.size()
#define printarray(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout<<*it<<" "; cout<<endl;
#define rep(n) for (ll i = 0; i < n; i++)
#define repc(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, x, y) for (int i = x; i < y; i++)
#define DEC(i, x, y) for (int i = x; i >= y; i--)
#define all(v) v.begin(), v.end()
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define alla(a, n) a, a + n
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (a * b)/gcd(a, b)
#define int long long int
#define ull unsigned long long
using namespace std;
const int MOD = 1e9 + 7;
const int MAXN = 1e5 + 5;
int fastexpo(int b, int exp){
if(exp == 0) return 1;
if(exp == 1) return b;
int ans = (fastexpo(b,exp/2) % MOD);
ans *= ans;
ans %= MOD;
if(exp % 2 == 1){
ans *= b;
}
ans %= MOD;
return ans;
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin>>n;
vector<pair<int, int> > vec;
for(int i =0;i<n;i++){
int t1, t2;
cin>>t1>>t2;
vec.pb(mp(t1, t2));
}
sort(all(vec));
int ans = 0;
int val2 = 0;
int val1 = 0;
for(int i= 0;i<n;i++){
val1 = max(val1, vec[i].fr-val2);
val2 += vec[i].sc;
ans = max(ans, val2 -vec[i].fr+ val1);
}
cout<<ans<<endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
4 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 |
4 ms |
384 KB |
Output is correct |
7 |
Correct |
4 ms |
384 KB |
Output is correct |
8 |
Correct |
5 ms |
384 KB |
Output is correct |
9 |
Correct |
5 ms |
384 KB |
Output is correct |
10 |
Correct |
4 ms |
384 KB |
Output is correct |
11 |
Correct |
5 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
4 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 |
4 ms |
384 KB |
Output is correct |
7 |
Correct |
4 ms |
384 KB |
Output is correct |
8 |
Correct |
5 ms |
384 KB |
Output is correct |
9 |
Correct |
5 ms |
384 KB |
Output is correct |
10 |
Correct |
4 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 |
384 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 |
512 KB |
Output is correct |
26 |
Correct |
5 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
4 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 |
4 ms |
384 KB |
Output is correct |
7 |
Correct |
4 ms |
384 KB |
Output is correct |
8 |
Correct |
5 ms |
384 KB |
Output is correct |
9 |
Correct |
5 ms |
384 KB |
Output is correct |
10 |
Correct |
4 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 |
384 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 |
512 KB |
Output is correct |
26 |
Correct |
5 ms |
384 KB |
Output is correct |
27 |
Correct |
6 ms |
640 KB |
Output is correct |
28 |
Correct |
7 ms |
640 KB |
Output is correct |
29 |
Correct |
7 ms |
640 KB |
Output is correct |
30 |
Correct |
7 ms |
640 KB |
Output is correct |
31 |
Correct |
7 ms |
640 KB |
Output is correct |
32 |
Correct |
7 ms |
640 KB |
Output is correct |
33 |
Correct |
6 ms |
640 KB |
Output is correct |
34 |
Correct |
7 ms |
640 KB |
Output is correct |
35 |
Correct |
7 ms |
640 KB |
Output is correct |
36 |
Correct |
7 ms |
640 KB |
Output is correct |
37 |
Correct |
7 ms |
640 KB |
Output is correct |
38 |
Correct |
7 ms |
640 KB |
Output is correct |
39 |
Correct |
7 ms |
640 KB |
Output is correct |
40 |
Correct |
6 ms |
640 KB |
Output is correct |
41 |
Correct |
7 ms |
640 KB |
Output is correct |
42 |
Correct |
7 ms |
640 KB |
Output is correct |
43 |
Correct |
7 ms |
640 KB |
Output is correct |
44 |
Correct |
7 ms |
640 KB |
Output is correct |
45 |
Correct |
7 ms |
640 KB |
Output is correct |
46 |
Correct |
7 ms |
640 KB |
Output is correct |
47 |
Correct |
7 ms |
640 KB |
Output is correct |
48 |
Correct |
7 ms |
640 KB |
Output is correct |
49 |
Correct |
7 ms |
640 KB |
Output is correct |
50 |
Correct |
7 ms |
640 KB |
Output is correct |
51 |
Correct |
7 ms |
640 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
4 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 |
4 ms |
384 KB |
Output is correct |
7 |
Correct |
4 ms |
384 KB |
Output is correct |
8 |
Correct |
5 ms |
384 KB |
Output is correct |
9 |
Correct |
5 ms |
384 KB |
Output is correct |
10 |
Correct |
4 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 |
384 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 |
512 KB |
Output is correct |
26 |
Correct |
5 ms |
384 KB |
Output is correct |
27 |
Correct |
6 ms |
640 KB |
Output is correct |
28 |
Correct |
7 ms |
640 KB |
Output is correct |
29 |
Correct |
7 ms |
640 KB |
Output is correct |
30 |
Correct |
7 ms |
640 KB |
Output is correct |
31 |
Correct |
7 ms |
640 KB |
Output is correct |
32 |
Correct |
7 ms |
640 KB |
Output is correct |
33 |
Correct |
6 ms |
640 KB |
Output is correct |
34 |
Correct |
7 ms |
640 KB |
Output is correct |
35 |
Correct |
7 ms |
640 KB |
Output is correct |
36 |
Correct |
7 ms |
640 KB |
Output is correct |
37 |
Correct |
7 ms |
640 KB |
Output is correct |
38 |
Correct |
7 ms |
640 KB |
Output is correct |
39 |
Correct |
7 ms |
640 KB |
Output is correct |
40 |
Correct |
6 ms |
640 KB |
Output is correct |
41 |
Correct |
7 ms |
640 KB |
Output is correct |
42 |
Correct |
7 ms |
640 KB |
Output is correct |
43 |
Correct |
7 ms |
640 KB |
Output is correct |
44 |
Correct |
7 ms |
640 KB |
Output is correct |
45 |
Correct |
7 ms |
640 KB |
Output is correct |
46 |
Correct |
7 ms |
640 KB |
Output is correct |
47 |
Correct |
7 ms |
640 KB |
Output is correct |
48 |
Correct |
7 ms |
640 KB |
Output is correct |
49 |
Correct |
7 ms |
640 KB |
Output is correct |
50 |
Correct |
7 ms |
640 KB |
Output is correct |
51 |
Correct |
7 ms |
640 KB |
Output is correct |
52 |
Correct |
230 ms |
20948 KB |
Output is correct |
53 |
Correct |
233 ms |
20948 KB |
Output is correct |
54 |
Correct |
227 ms |
20944 KB |
Output is correct |
55 |
Correct |
246 ms |
20948 KB |
Output is correct |
56 |
Correct |
223 ms |
20948 KB |
Output is correct |
57 |
Correct |
245 ms |
20948 KB |
Output is correct |
58 |
Correct |
234 ms |
20948 KB |
Output is correct |
59 |
Correct |
231 ms |
21080 KB |
Output is correct |
60 |
Correct |
224 ms |
20948 KB |
Output is correct |
61 |
Correct |
226 ms |
20820 KB |
Output is correct |
62 |
Correct |
238 ms |
20948 KB |
Output is correct |
63 |
Correct |
229 ms |
21044 KB |
Output is correct |
64 |
Correct |
232 ms |
20948 KB |
Output is correct |
65 |
Correct |
235 ms |
21080 KB |
Output is correct |
66 |
Correct |
228 ms |
21080 KB |
Output is correct |
67 |
Correct |
228 ms |
20952 KB |
Output is correct |
68 |
Correct |
234 ms |
20948 KB |
Output is correct |