# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
924821 | SalihSahin | Art Exhibition (JOI18_art) | C++17 | 173 ms | 36748 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define pb push_back
#define int long long
#define mp make_pair
using namespace std;
const int mod = 998244353;
const int inf = 1e16;
const int N = 55;
int32_t main(){
cin.tie(0); cout.tie(0);
ios_base::sync_with_stdio(false);
int n;
cin>>n;
vector<pair<int, int> > a(n);
vector<int> vp(n+1);
for(int i = 0; i < n; i++){
cin>>a[i].first>>a[i].second;
}
sort(a.begin(), a.end());
for(int i = 0; i < n; i++){
vp[i+1] = vp[i] + a[i].second;
}
vector<pair<int, int> > pre(n);
vector<int> v(n);
v[0] = a[0].second;
for(int i = 1; i < n; i++){
v[i] = a[i].second - (a[i].first - a[i-1].first);
}
pre[0].first = v[0];
pre[0].second = 0;
for(int i = 1; i < n; i++){
pre[i].first = pre[i-1].first + v[i];
pre[i].second = i;
}
sort(pre.rbegin(), pre.rend());
int pind = 0;
int ans = 0;
for(int i = 0; i < n; i++){
while(pind < pre.size()-1 && pre[pind].second < i){
pind++;
}
int x = pre[pind].second;
int c = (vp[x+1] - vp[i]) - (a[x].first - a[i].first);
ans = max(ans, c);
}
cout<<ans<<endl;
return 0;
}
컴파일 시 표준 에러 (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... |