結果
| 問題 | No.2035 Tunnel |
| コンテスト | |
| ユーザー |
srjywrdnprkt
|
| 提出日時 | 2023-05-11 00:29:24 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
AC
|
| 実行時間 | 6 ms / 2,000 ms |
| コード長 | 592 bytes |
| 記録 | |
| コンパイル時間 | 640 ms |
| コンパイル使用メモリ | 128,196 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-06-30 14:10:45 |
| 合計ジャッジ時間 | 2,498 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 28 |
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:30:22: warning: 'm' may be used uninitialized [-Wmaybe-uninitialized]
30 | for (int i=N-1; i>=m+1; i--){
| ~^~~~~
main.cpp:19:19: note: 'm' was declared here
19 | int N, ans=0, m;
| ^
ソースコード
#include <iostream>
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <iomanip>
#include <queue>
#include <algorithm>
#include <numeric>
#include <deque>
#include <complex>
#include <cassert>
using namespace std;
using ll = long long;
int main(){
int N, ans=0, m;
string S;
cin >> N >> S;
for (int i=0; i<N; i++){
if (S[i] == '#'){
m = i;
break;
}
}
for (int i=N-1; i>=m+1; i--){
if (S[i] == '#') ans++;
else ans = max(0, ans-1);
}
cout << ans+N-m << endl;
return 0;
}
srjywrdnprkt