| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1363319 | AMnu | Safety (NOI18_safety) | C++20 | 56 ms | 3648 KiB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int N, H, A;
ll ans, sh;
priority_queue <ll> lef;
priority_queue <ll,vector<ll>,greater<ll> > rig;
int main () {
cin >> N >> H >> A;
lef.push(A);
rig.push(A);
for (int i=1;i<N;i++) {
cin >> A;
sh += H;
if (A < lef.top()-sh) {
ans += (lef.top()-sh) - A;
rig.push(lef.top()-sh-sh);
lef.pop();
lef.push(A+sh);
lef.push(A+sh);
}
else if (A > rig.top()+sh) {
ans += A - (rig.top()+sh);
lef.push(rig.top()+sh+sh);
rig.pop();
rig.push(A-sh);
rig.push(A-sh);
}
else {
lef.push(A+sh);
rig.push(A-sh);
}
}
cout << ans << "\n";
}
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
