# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
582046 | hibiki | Art Exhibition (JOI18_art) | C++11 | 253 ms | 14188 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
int n;
long long a[500005],b[500005];
long long ans = 0, dp[500005];
vector<int> v;
int main()
{
scanf("%d",&n);
for(int i = 0; i < n; i++)
{
scanf("%lld %lld",&a[i],&b[i]);
v.pb(i);
}
sort(v.begin(),v.end(), [&](const int x, const int y){
return a[x] < a[y];
});
for(int i = 0; i < n; i++)
{
dp[i] = b[v[i]];
if(i)
dp[i] += max(0ll, dp[i - 1] - (a[v[i]] - a[v[i - 1]]));
ans = max(ans,dp[i]);
}
printf("%lld\n",ans);
}
컴파일 시 표준 에러 (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... |