# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1082008 | lamlamlam | Art Exhibition (JOI18_art) | C++17 | 159 ms | 36944 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
const int MN = 5e5+5;
int n;
__int128 pre[MN],suf[MN],ans,tmp;
pair<int,int> a[MN];
void printt(__int128 x)
{
string res = "";
if(x==0) {
cout << 0;
return;
}
bool am = false;
if(x<0) am = true, x = -x;
while(x!=0){
res += '0' + x%10;
x /= 10;
}
if(am) cout << '-';
for(int i=res.size()-1; i>=0; i--) cout << res[i];
}
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
#define task "JOI18_ART"
if(fopen(task".inp","r")){
freopen(task".inp","r",stdin);
freopen(task".out","w",stdout);
}
cin >> n;
for(int i=1; i<=n; i++) cin >> a[i].first >> a[i].second;
sort(a+1,a+1+n);
for(int i=1; i<=n; i++) pre[i] = a[i].second - (a[i].first-a[i-1].first);
for(int i=1; i<=n; i++) pre[i] += pre[i-1];
suf[n+1] = -1e36;
for(int i=n; i>0; i--) suf[i] = max(suf[i+1],pre[i]);
ans = a[n].second;
for(int i=1; i<n; i++) {
tmp = a[i].second;
ans = max(ans,tmp+suf[i]-pre[i]);
}
printt(ans);
cerr << "\nTime: " << 1000.0 * clock() / CLOCKS_PER_SEC << endl;
}
컴파일 시 표준 에러 (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... |