結果
問題 | No.3017 交互浴 |
ユーザー |
![]() |
提出日時 | 2024-12-30 22:44:47 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 337 ms / 2,000 ms |
コード長 | 341 bytes |
コンパイル時間 | 6,637 ms |
コンパイル使用メモリ | 260,120 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2025-01-25 21:55:38 |
合計ジャッジ時間 | 17,261 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge7 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 55 |
ソースコード
#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;}}