# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1269244 | i_lov_aris | Art Exhibition (JOI18_art) | C++20 | 122 ms | 8268 KiB |
#include<bits/stdc++.h>
/*
--> Programmed by katamori1310 <--
ᓀ‸ᓂ
Chillin with Blue Archive
*/
#define int long long
#define ull unsigned long long
#define aris ""
using namespace std;
const int MAXN = 100000;
const int MOD = 1e9 + 7;
const int MAXP = 1e6;
const int INF = 1e18;
const int MODE = MOD - 2;
/*
I love Aris and Kei at the same time
☆ ☆ ☆ Pampakapam ☆ ☆ ☆
*/
inline void kei(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
}
int n;
pair<int, int>a[5 * MAXN + 5];
int pfs[5 * MAXN + 5];
void solve(){
cin >> n;
for(int i = 1; i <= n; i++){
cin >> a[i].first >> a[i].second;
}
sort(a + 1, a + n + 1);
int pref = 0;
int cur = INF;
int res = -INF;
for(int i = 1; i <= n; i++){
cur = min(cur, pref - a[i].first);
pref += a[i].second;
res = max(res, pref - a[i].first - cur);
}
cout << res << "\n";
}
signed main(){
if(fopen(aris".inp", "r")){
freopen(aris".inp", "r", stdin);
freopen(aris".out", "w", stdout);
}
kei();
int T;
// cin >> T;
T = 1;
while(T--){
solve();
}
return 0;
}
// 눈‸눈
Compilation message (stderr)
# | 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... |