結果
| 問題 | No.3017 交互浴 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-01-25 19:28:56 |
| 言語 | C++14 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
AC
|
| 実行時間 | 149 ms / 2,000 ms |
| コード長 | 582 bytes |
| 記録 | |
| コンパイル時間 | 451 ms |
| コンパイル使用メモリ | 81,868 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-06-24 09:29:38 |
| 合計ジャッジ時間 | 12,105 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 55 |
ソースコード
#include<iostream>
#include<stack>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int N;
cin>>N;
stack<int> st;
st.push(2e9);
int wb=0;
rep(i,N){
int H;
cin>>H;
int mae=0;
while(st.top()<H){
if(st.size()%2==0) wb-=st.top()-mae;
mae=st.top();
st.pop();
}
if(st.size()%2==0) wb-=H-mae;
if(i%2==0) wb+=H;
if((st.size()+i)%2) st.push(H);
cout<<wb<<endl;
}
}