답안 #1101898

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1101898 2024-10-17T07:18:13 Z Warinchai Safety (NOI18_safety) C++14
컴파일 오류
0 ms 0 KB
#include<bits/stdc++.h>
#define int long long
using namespace std;
priority_queue<int,vector<int>,greater<int>>r;
priority_queue<int>l;
int ar[200005];
int lzl,lzr;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n,h;cin>>n>>h;
    for(int i=1;i<=n;i++){
        cin>>ar[i];
    }
    int ans=0;
    for(int i=1;i<=n;i++){
        if(i!=1&&ar[i]<l.top()+lzl){
            ans+=l.top()+lzl-ar[i];
            l.push(ar[i]-lzl);
            l.push(ar[i]-lzl);
            r.push(l.top()+lzl-lzr);
            l.pop();
        }else if(i!=1&&ar[i]>r.top()+lzr){
            ans+=ar[i]-r.top()-lzr;
            r.push(ar[i]-lzr);
            r.push(ar[i]-lzr);
            l.push(r.top()+lzr-lzl);
            r.pop();
        }else{
            l.push(ar[i]-lzl);
            r.push(ar[i]-lzr);
        }
        lzl-=h;
        lzr+=h;
    }
    cout<<ans;
}

Compilation message

cc1plus: error: '::main' must return 'int'