답안 #868476

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
868476 2023-10-31T13:59:48 Z Warinchai Safety (NOI18_safety) C++14
5 / 100
40 ms 3680 KB
#include<bits/stdc++.h>
#pragma GCC optimize("O3","unroll-loops")
#pragma GCC target ("avx2")
using namespace std;
priority_queue<long long>pql;
priority_queue<long long,vector<long long>,greater<long long> >pqr;
long long lzl,lzr;
int a,b,c;
long long ans=0;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n,h;
    cin>>n>>h;
    for(int i=0;i<n;i++){
        cin>>a;
        b=a-lzl,c=a-lzr;
        if(i>0&&a<pql.top()+lzl){
            //cout<<"left\n";
            pql.push(b);
            pql.push(b);
            ans+=abs(b-pql.top());
            pqr.push(pql.top()+lzl-lzr);
            pql.pop();
        }else if(i>0&&a>pqr.top()+lzr){
            //cout<<"right\n";
            pqr.push(c);
            pqr.push(c);
            ans+=abs(b-pqr.top());
            pql.push(pqr.top()+lzr-lzl);
            pqr.pop();
        }else{
            //cout<<"middle\n";
            pql.push(b);
            pqr.push(c);
        }
        lzl-=h;
        lzr+=h;
        //cout<<ans<<" ";
    }
    cout<<ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Incorrect 0 ms 348 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 27 ms 3488 KB Output is correct
2 Correct 40 ms 3680 KB Output is correct
3 Correct 40 ms 3484 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Incorrect 0 ms 348 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Incorrect 0 ms 348 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Incorrect 0 ms 348 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Incorrect 0 ms 348 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Incorrect 0 ms 348 KB Output isn't correct
7 Halted 0 ms 0 KB -