結果
問題 | No.2035 Tunnel |
ユーザー |
|
提出日時 | 2022-08-12 22:31:00 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 5 ms / 2,000 ms |
コード長 | 416 bytes |
コンパイル時間 | 1,935 ms |
コンパイル使用メモリ | 194,332 KB |
最終ジャッジ日時 | 2025-01-30 21:22:31 |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 28 |
ソースコード
#include<bits/stdc++.h> using namespace std; int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int N; string S; cin>>N>>S; if(N==1){ cout<<"1\n"; return 0; } vector<int>w(N); int ans=0; for(int i=N-1;i>0;i--){ if(S[i]=='#'){ w[i-1]=w[i]+1; ans=(N-i)+w[i]; }else{ w[i-1]=max(0,w[i]-1); } } if(S[0]=='#'){ ans=N+w[0]; } cout<<ans<<'\n'; }