結果
| 問題 |
No.3017 交互浴
|
| コンテスト | |
| ユーザー |
DeltaStruct
|
| 提出日時 | 2024-12-30 22:31:59 |
| 言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 437 bytes |
| コンパイル時間 | 6,188 ms |
| コンパイル使用メモリ | 262,324 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2025-01-25 22:11:08 |
| 合計ジャッジ時間 | 26,552 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 53 WA * 2 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main(){
int n; cin >> n; vector<int> A(n); for (int& a:A) cin >> a;
stack<pair<int,int>> s; int res = 0; s.emplace(1,(int)1e9);
for (int i(0);i < n;++i){
while(!s.empty()&&s.top().second<=A[i]){
auto [a,b] = s.top(); s.pop();
res += (a?1:-1)*b;
}
if (s.empty()||s.top().first!=i%2) s.emplace(i%2,A[i]),res += (i%2?-1:1)*A[i];
cout << res << endl;
}
}
DeltaStruct