結果
問題 | No.3017 交互浴 |
ユーザー |
|
提出日時 | 2025-02-01 20:07:33 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 652 bytes |
コンパイル時間 | 5,316 ms |
コンパイル使用メモリ | 276,452 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2025-02-01 20:07:50 |
合計ジャッジ時間 | 14,752 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 7 WA * 48 |
ソースコード
#include <bits/stdc++.h>using namespace std;int main() {std::ios::sync_with_stdio(false);std::cin.tie(nullptr);int N;cin >> N;vector<pair<int, int>> st;int64_t ans = 0;for(int i = 0; i < N; i++) {int H;cin >> H;while(!st.empty() && (st.back().first <= H || st.back().second == i % 2)) {auto[h, p] = st.back();st.pop_back();if(p == 0) ans -= h;else ans += h;if(p == i % 2) H = max(H, h);}st.push_back({H, i % 2});if(i % 2 == 0) ans += H;else ans -= H;cout << ans << '\n';}}