Submission #1166117

#TimeUsernameProblemLanguageResultExecution timeMemory
1166117spycoderytSafety (NOI18_safety)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #define int long long using namespace std; int main() { int n,h,x,ans=0; cin >> n >> h; priority_queue<int> lq; priority_queue<int,vector<int>,greater<int> > rq; for(int i = 0;i<n;i++) { cin >> x; if(i==0){ lq.push(x); rq.push(x); continue; } int range = i * h; if(x + range < lq.top()) { lq.push(x+range); ans += abs(lq.top() - (x+range)); lq.push(x+range); rq.push(lq.top() - 2 * range); lq.pop(); } else if (x - range > rq.top()) { rq.push(x-range); ans += abs(rq.top() - (x - range)); rq.push(x-range); lq.push(rq.top() + 2 * range); rq.pop(); } else { lq.push(x+range); rq.push(x-range); } } cout<<ans; }

Compilation message (stderr)

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