#include <bits/stdc++.h>
#pragma GCC optimize ("Ofast")
#define F first
#define S second
#define p_b push_back
#define ll long long
#define int long long
using namespace std ;
const int MOD = 1e9 + 7 ;
const int INF = 2e9 ;
int n , m , k ;
vector <pair <int , int>> a , b ;
set <int> s ;
void solve (){
cin >> n ;
a.resize (n) ;
for (auto &i : a)
cin >> i.F >> i.S ;
sort (a.begin () , a.end ()) ;
int ans = 0 ;
for (int i = 0 ; i < n ; i++){
int sum = 0 ;
for (int j = i ; j < n ; j++){
sum += a [j].S ;
ans = max (ans , sum - (a [j].F - a [i].F)) ;
}
}
cout << ans ;
}
int32_t main (){
ios_base::sync_with_stdio (0) ; cin.tie (0) ; cout.tie (0) ;
int t = 1 ;
//cin >> t ;
while (t--){
solve () ;
cout << '\n' ;
}
return 0 ;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |