#include <algorithm>
#include <fstream>
#include <vector>
#include <queue>
#include <stack>
#include <iostream>
#include <cmath>
#include <queue>
#include <set>
#include <string>
#include <cstring>
#include <map>
#include <unordered_map>
#include <unordered_set>
#define F first
#define S second
#define PB push_back
using namespace std;
const long long MOD=1e9+7, INF=1e18;
const int INFI=1e9;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<pair<int, ii>> viii;
typedef vector<vii> vvii;
typedef vector<ll> vll;
typedef vector<vll> vvll;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n; cin>>n;
vll pref(n+1, 0);
vector<pair<ll, ll>> info(n);
for(auto &num:info) cin>>num.F>>num.S;
sort(info.begin(), info.end());
for(int i=1;i<=n;i++) pref[i]+=pref[i-1]+info[i-1].S;
ll ans=0;
for(int i=0;i<n;i++)
for(int j=i;j<n;j++)
ans=max(ans, pref[j+1]-pref[i]-info[j].F+info[i].F);
cout<<ans<<endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
420 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
344 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
420 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
344 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
344 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
344 KB |
Output is correct |
15 |
Correct |
0 ms |
344 KB |
Output is correct |
16 |
Correct |
1 ms |
344 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
22 |
Correct |
0 ms |
464 KB |
Output is correct |
23 |
Correct |
0 ms |
348 KB |
Output is correct |
24 |
Correct |
1 ms |
348 KB |
Output is correct |
25 |
Correct |
0 ms |
348 KB |
Output is correct |
26 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
420 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
344 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
344 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
344 KB |
Output is correct |
15 |
Correct |
0 ms |
344 KB |
Output is correct |
16 |
Correct |
1 ms |
344 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
22 |
Correct |
0 ms |
464 KB |
Output is correct |
23 |
Correct |
0 ms |
348 KB |
Output is correct |
24 |
Correct |
1 ms |
348 KB |
Output is correct |
25 |
Correct |
0 ms |
348 KB |
Output is correct |
26 |
Correct |
0 ms |
348 KB |
Output is correct |
27 |
Correct |
13 ms |
696 KB |
Output is correct |
28 |
Correct |
14 ms |
604 KB |
Output is correct |
29 |
Correct |
13 ms |
680 KB |
Output is correct |
30 |
Correct |
13 ms |
600 KB |
Output is correct |
31 |
Correct |
13 ms |
600 KB |
Output is correct |
32 |
Correct |
14 ms |
700 KB |
Output is correct |
33 |
Correct |
14 ms |
696 KB |
Output is correct |
34 |
Correct |
13 ms |
604 KB |
Output is correct |
35 |
Correct |
16 ms |
600 KB |
Output is correct |
36 |
Correct |
16 ms |
604 KB |
Output is correct |
37 |
Correct |
13 ms |
604 KB |
Output is correct |
38 |
Correct |
13 ms |
604 KB |
Output is correct |
39 |
Correct |
13 ms |
600 KB |
Output is correct |
40 |
Correct |
16 ms |
600 KB |
Output is correct |
41 |
Correct |
14 ms |
604 KB |
Output is correct |
42 |
Correct |
13 ms |
604 KB |
Output is correct |
43 |
Correct |
13 ms |
604 KB |
Output is correct |
44 |
Correct |
13 ms |
604 KB |
Output is correct |
45 |
Correct |
13 ms |
604 KB |
Output is correct |
46 |
Correct |
13 ms |
600 KB |
Output is correct |
47 |
Correct |
14 ms |
600 KB |
Output is correct |
48 |
Correct |
13 ms |
604 KB |
Output is correct |
49 |
Correct |
14 ms |
700 KB |
Output is correct |
50 |
Correct |
13 ms |
604 KB |
Output is correct |
51 |
Correct |
13 ms |
856 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
420 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
344 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
344 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
344 KB |
Output is correct |
15 |
Correct |
0 ms |
344 KB |
Output is correct |
16 |
Correct |
1 ms |
344 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
22 |
Correct |
0 ms |
464 KB |
Output is correct |
23 |
Correct |
0 ms |
348 KB |
Output is correct |
24 |
Correct |
1 ms |
348 KB |
Output is correct |
25 |
Correct |
0 ms |
348 KB |
Output is correct |
26 |
Correct |
0 ms |
348 KB |
Output is correct |
27 |
Correct |
13 ms |
696 KB |
Output is correct |
28 |
Correct |
14 ms |
604 KB |
Output is correct |
29 |
Correct |
13 ms |
680 KB |
Output is correct |
30 |
Correct |
13 ms |
600 KB |
Output is correct |
31 |
Correct |
13 ms |
600 KB |
Output is correct |
32 |
Correct |
14 ms |
700 KB |
Output is correct |
33 |
Correct |
14 ms |
696 KB |
Output is correct |
34 |
Correct |
13 ms |
604 KB |
Output is correct |
35 |
Correct |
16 ms |
600 KB |
Output is correct |
36 |
Correct |
16 ms |
604 KB |
Output is correct |
37 |
Correct |
13 ms |
604 KB |
Output is correct |
38 |
Correct |
13 ms |
604 KB |
Output is correct |
39 |
Correct |
13 ms |
600 KB |
Output is correct |
40 |
Correct |
16 ms |
600 KB |
Output is correct |
41 |
Correct |
14 ms |
604 KB |
Output is correct |
42 |
Correct |
13 ms |
604 KB |
Output is correct |
43 |
Correct |
13 ms |
604 KB |
Output is correct |
44 |
Correct |
13 ms |
604 KB |
Output is correct |
45 |
Correct |
13 ms |
604 KB |
Output is correct |
46 |
Correct |
13 ms |
600 KB |
Output is correct |
47 |
Correct |
14 ms |
600 KB |
Output is correct |
48 |
Correct |
13 ms |
604 KB |
Output is correct |
49 |
Correct |
14 ms |
700 KB |
Output is correct |
50 |
Correct |
13 ms |
604 KB |
Output is correct |
51 |
Correct |
13 ms |
856 KB |
Output is correct |
52 |
Execution timed out |
1040 ms |
24724 KB |
Time limit exceeded |
53 |
Halted |
0 ms |
0 KB |
- |