# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
834468 | urieg | Safety (NOI18_safety) | C++17 | 45 ms | 5404 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define ve vector
typedef long long ll;
using namespace std;
int main(){
// ios_base::sync_with_stdio(0);cin.tie(0);
ll n, a, h;
priority_queue<ll>ql;
priority_queue<ll, vector<ll>, greater<ll>>qr;
long long ans = 0, h1=0,h2=0;
scanf("%lld%lld%lld", &n, &h, &a);
ql.push(a);
qr.push(a);
for(int i = 1; i<n; i++){
h1 -= h;
h2 += h;
scanf("%lld", &a);
if(ql.top()+h1<a && a<qr.top()+h2){
ql.push(a-h1);
qr.push(a-h2);
}
else if(a <= ql.top()+h1){
ans += ql.top()+h1 - a;
ql.push(a-h1);
ql.push(a-h1);
qr.push(ql.top()+h1-h2);
ql.pop();
}
else if(qr.top()+h2 <= a){
ans += a - qr.top()-h2;
qr.push(a-h2);
qr.push(a-h2);
ql.push(qr.top()+h2-h1);
qr.pop();
}
}
cout<<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... |
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |