# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
387519 | CaroLinda | Safety (NOI18_safety) | C++14 | 69 ms | 3744 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define ll long long
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define sz(x) (int)(x.size())
#define mkt make_tuple
#define lp(i,a,b) for(int i = a ; i < b ; i++ )
#define debug printf
const int MAXN = 2e5+10 ;
using namespace std ;
int N ;
ll H , ans ;
priority_queue<ll> lef ;
priority_queue< ll , vector<ll>, greater<ll> > rig ;
ll lzLef , lzRig ;
int main()
{
scanf("%d %lld", &N, &H ) ;
for(int i = 1 ; i <= N ; i++ , lzLef -= H , lzRig += H )
{
ll x ;
scanf("%lld", &x ) ;
if(lef.empty())
{
assert(i == 1 ) ;
lef.push(x) ;
rig.push(x);
}
else
{
if( x >= lef.top()+lzLef )
{
rig.push( x-lzRig ) ;
rig.push( x-lzRig ) ;
lef.push( rig.top()+lzRig-lzLef ) ;
rig.pop() ;
ans += abs(x-(lef.top()+lzLef) ) ;
}
else
{
lef.push(x-lzLef) ;
lef.push( x-lzLef ) ;
rig.push( lef.top()+lzLef-lzRig ) ;
lef.pop() ;
ans += abs( x-(rig.top()+lzRig) ) ;
}
}
}
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... |
# | 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... |