# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
50709 | gnoor | Art Exhibition (JOI18_art) | C++17 | 1008 ms | 39812 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <cstdio>
#include <map>
#include <algorithm>
#include <vector>
using namespace std;
map<long long,long long> mp;
long long sz[500100];
long long val[500100];
int main () {
int n;
scanf("%d",&n);
long long a,b;
for (int i=0;i<n;i++) {
scanf("%lld%lld",&a,&b);
mp[a]+=b;
}
int nn=0;
for (auto &i:mp) {
//printf("%lld %lld\n",i.first,i.second);
sz[nn]=i.first;
val[nn]=i.second;
if (nn) val[nn]+=val[nn-1];
nn++;
}
long long mnn=-sz[0];
long long ans=0;
for (int i=0;i<nn;i++) {
ans=max(ans,val[i]-sz[i]-mnn);
mnn=min(mnn,val[i]-sz[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... |