//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("Ofast,unroll-loops,fast-math,O3")
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <fstream>
#include <unordered_map>
#define ll long long
#define int long long
#define all(v) v.begin(), v.end()
#define nl '\n'
#define pb push_back
#define sz(s) (int)(s).size()
#define f first
#define s second
using namespace std;
const ll N = 1e5 + 50, MX = 1e18;
vector <pair <int, int> > g[N];
bool was[N], fr[N];
void solve(){
ll n;
cin >> n;
pair <int, int> p[n+1];
for(int i = 1; i <= n; i++){
cin >> p[i].f >> p[i].s;
}
sort(p + 1, p + 1 + n);
ll ans = 0;
ll pr[n+1];
pr[0]=0;
pr[1] = p[1].s;
for(int i = 2; i <= n; i++){
pr[i] = pr[i-1]+p[i].s;
}
for(int l = 1; l <= n; l++){
for(int r = l+1; r <= n; r++){
ans = max((pr[r] - pr[l-1]) - (p[r].f - p[l].f), ans);
//cout << r << " " << l << " " << p[r].f << " " << p[l].f << " " << pr[r] - pr[l-1] << nl;
}
}
cout << ans << nl;
}
signed main(){
//freopen("lca.in", "r", stdin);
//freopen("lca.out", "w", stdout);
ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
ll ql=1;
//cin >> ql;
//tst++;
while(ql--){
solve();
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
2648 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
2648 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
2648 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
2648 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |