結果

問題 No.3017 交互浴
コンテスト
ユーザー DeltaStruct
提出日時 2024-12-30 22:44:47
言語 C++17(gcc12)
(gcc 12.4.0 + boost 1.92.0 + ACL)
コンパイル:
g++-12 -O2 -fplugin=/usr/lib/yukicoder/noavx512-gcc12.so -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 483 ms / 2,000 ms
+ 2µs
コード長 341 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 3,427 ms
コンパイル使用メモリ 207,492 KB
実行使用メモリ 7,852 KB
最終ジャッジ日時 2026-10-21 04:30:40
合計ジャッジ時間 46,161 ms
ジャッジサーバーID
(参考情報)
judge6_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 57
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;

int main(){
  int n,r = 0; cin >> n; stack<pair<int,int>> s({make_pair(1,1e9+1)});
  for (int i(0),x;i < n;++i){
    cin >> x; while(s.top().second<=x) r += (s.top().first?1:-1)*s.top().second,s.pop();
    if (s.top().first!=i%2) s.emplace(i%2,x),r += (i%2?-1:1)*x;
    cout << r << endl;
  }
}
0