結果
| 問題 |
No.3017 交互浴
|
| コンテスト | |
| ユーザー |
umezo
|
| 提出日時 | 2025-01-27 07:19:24 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 902 bytes |
| コンパイル時間 | 3,287 ms |
| コンパイル使用メモリ | 280,000 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2025-01-27 07:19:38 |
| 合計ジャッジ時間 | 12,723 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 2 WA * 53 |
ソースコード
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
#include<bits/stdc++.h>
using namespace std;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int n;
cin>>n;
V<int> H(n);
rep(i,n) cin>>H[i];
stack<pair<int,int>> st;
V<int> ANS(n);
st.push({H[0],0});
ANS[0]=H[0];
int sum=H[0];
for(int i=1;i<n;i++){
while(st.size() && st.top().first<=H[i]){
auto a=st.top();
st.pop();
if(a.second==0) sum-=a.first;
else sum+=a.first;
}
if(i%2==0){
if(st.empty()) sum+=H[i];
else if(st.top().second==1) sum+=H[i];
}
else{
if(st.empty()) sum-=H[i];
else if(st.top().second==0) sum-=H[i];
}
ANS[i]=sum;
st.push({H[i],i%2});
}
rep(i,n) cout<<ANS[i]<<'\n';
return 0;
}
umezo