結果
問題 |
No.3017 交互浴
|
ユーザー |
![]() |
提出日時 | 2025-01-25 13:18:42 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 777 bytes |
コンパイル時間 | 7,019 ms |
コンパイル使用メモリ | 260,080 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2025-01-25 22:42:52 |
合計ジャッジ時間 | 27,740 ms |
ジャッジサーバーID (参考情報) |
judge10 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 3 WA * 52 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; vector<int> H(N + 1); for (int i = 1; i <= N; ++i) cin >> H[i]; stack<pair<int, int>> st; int ans = 0; int prev = 0; st.push(make_pair(1000000010, 0)); for (int i = 1; i <= N; ++i) { while (st.top().first <= H[i]) { if (st.top().second % 2 == 0) ans += st.top().first; else ans -= st.top().first; st.pop(); } if (st.top().second % 2 != i % 2) { if (i % 2 == 1) ans += H[i]; else ans -= H[i]; } st.push(make_pair(H[i], i)); cout << ans << endl; } return 0; }