이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define lop(i,a,b) for(ll i = a; i < b; i++)
#define alop(i,v) for(auto i: v)
#define ll long long
#define all(v) v.begin(),v.end()
#define pb push_back
using namespace std;
int main(){
ll n, t1, t2; cin >> n;
ll arr[n];
vector<pair<ll,ll>> v, m;
lop(i,0,n){
cin >> t1 >> t2;
v.pb({t1,t2});
}
sort(all(v));
int i = 0;
alop(it,v){
if(i == 0) arr[0] = it.second;
else arr[i] = it.second + arr[i-1];
i++;
}
ll mx = -1e18;
for(int i = 0; i < n; i++){
for(int j = 0; j < n; j++){
if(i+j >= n) break;
ll sum = arr[i+j];
if(j == 0) mx = max(mx, sum - arr[i+j-1]);
else{
if(i != 0) sum -= arr[i-1];
mx = max(mx, sum - (v[i+j].first - v[i].first));
}
}
}
cout << mx;
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... |