| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 970645 | Roumak77 | Art Exhibition (JOI18_art) | Cpython 3 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("-Ofast")
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <limits>
#include <cmath>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
using namespace std;
using ll = long long;
void solve(){
ll n;
cin >> n;
vector<pair<ll, ll>> list_n(n, pair<ll, ll>{0, 0});
for(ll i = 0; i < n; i++){
cin >> list_n[i].first;
cin >> list_n[i].second;
}
sort(list_n.begin(), list_n.end());
ll curr_max = -1E15 - 5;
for(ll i = 0; i < n; i++){
ll start = list_n[i].first;
ll curr = 0;
for(ll j = i; j < n; j++){
curr += list_n[j].second;
curr_max = max(curr_max, curr - list_n[j].first + start);
}
}
cout << curr_max << endl;
}
int main(){
ios_base::sync_with_stdio(false);
cout.tie(0);
cin.tie(0);
ll t = 1;
while(t--){
solve();
}
}
