| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 | 
|---|---|---|---|---|---|---|---|
| 295602 | RezwanArefin01 | Safety (NOI18_safety) | C++17 | 99 ms | 5528 KiB | 
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
const int N = 2e5 + 5;
int n, h, X;
template <class T>
struct shift_pq {
  T Q;
  ll total;
  shift_pq() : total(0) {}
  void shift(ll X) {
    total += X;
  }
  void push(ll X) {
    Q.push(X - total);
  }
  ll top() {
    return Q.top() + total;
  }
  void pop() {
    Q.pop();
  }
};
int main() {
#ifdef LOCAL
  freopen("in", "r", stdin);
#endif
  scanf("%d %d", &n, &h);
  shift_pq<priority_queue<ll>> L;
  shift_pq<priority_queue<ll, vector<ll>, greater<ll>>> R;
  ll ans = 0;
  for (int i = 0; i < n; ++i) {
    scanf("%d", &X);
    L.shift(-h);
    R.shift(h);
    L.push(X);
    R.push(X);
    if (X < L.top()) {
      ans += L.top() - X;
      L.push(X);
      R.push(L.top());
      R.pop();
      L.pop();
    } else if (X > R.top()) {
      ans += X - R.top();
      R.push(X);
      L.push(R.top());
      L.pop();
      R.pop();
    }
  }
  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... | ||||
