# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
559799 | krit3379 | Safety (NOI18_safety) | C++17 | 40 ms | 4808 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#define N 200005
typedef long long ll;
ll x,h,shift,ymin;
priority_queue<ll> l;
priority_queue<ll,vector<ll>,greater<ll>> r;
int main(){
int n;
scanf("%d %lld",&n,&h);
scanf("%lld",&x);
l.push(x),r.push(x);
while(--n){
scanf("%lld",&x);
shift+=h;
if(x<l.top()-shift){
ymin+=l.top()-shift+x;
r.push(l.top()-2*shift);
l.pop();
l.push(x+shift);
l.push(x+shift);
}
else if(x>r.top()+shift){
ymin+=x-r.top()-shift;
l.push(r.top()+2*shift);
r.pop();
r.push(x-shift);
r.push(x-shift);
}
else{
l.push(x+shift);
r.push(x-shift);
}
}
printf("%lld",ymin);
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... |