# | 제출 시각UTC-0 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
229370 | DodgeBallMan | Candies (JOI18_candies) | C++14 | 399 ms | 19576 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define pii pair<long, long>
#define x first
#define y second
using namespace std;
const int N = 2e5 + 10;
int n, L[N], R[N];
long long A[N];
set<pii> S;
int main()
{
scanf("%d",&n);
for( int i = 1 ; i <= n ; i++ ) {
scanf("%lld", A + i);
if( i > 1 ) L[i] = i - 1;
if( i < n ) R[i] = i + 1;
S.emplace( A[i], i );
}
long long ans = 0;
for( int i = 1 ; i <= ( n + 1 ) / 2 ; i++ ) {
int now = S.rbegin()->y;
printf("%lld\n",ans += A[now]);
S.erase( pii( A[now], now ) );
int l = L[now], r = R[now];
if( l ) S.erase( pii( A[l], l ) );
if( r ) S.erase( pii( A[r], r ) );
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |