# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
41097 | IvanC | Art Exhibition (JOI18_art) | C++14 | 290 ms | 12508 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> ii;
const int MAXN = 5*1e5 + 10;
ii vetor[MAXN];
ll soma[MAXN],maximo,N,ans;
int main(){
scanf("%lld",&N);
for(ll i = 1;i<=N;i++){
scanf("%lld %lld",&vetor[i].first,&vetor[i].second);
}
sort(vetor+1,vetor+N+1);
for(ll i = 1;i<=N;i++){
soma[i] = soma[i-1] + vetor[i].second;
}
maximo = soma[N] - vetor[N].first;
for(ll i = N;i>=1;i--){
maximo = max(maximo, soma[i] - vetor[i].first );
ans = max(ans, maximo + vetor[i].first - soma[i-1] );
}
printf("%lld\n",ans);
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... |