結果

問題 No.2035 Tunnel
ユーザー zezerozezero
提出日時 2022-08-12 22:20:45
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 749 bytes
コンパイル時間 3,132 ms
コンパイル使用メモリ 167,760 KB
実行使用メモリ 4,960 KB
最終ジャッジ日時 2023-10-24 10:32:59
合計ジャッジ時間 4,237 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 11 ms
4,960 KB
testcase_06 AC 11 ms
4,960 KB
testcase_07 WA -
testcase_08 AC 9 ms
4,960 KB
testcase_09 WA -
testcase_10 AC 10 ms
4,960 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 5 ms
4,348 KB
testcase_23 AC 3 ms
4,348 KB
testcase_24 AC 7 ms
4,348 KB
testcase_25 AC 8 ms
4,576 KB
testcase_26 AC 7 ms
4,348 KB
testcase_27 AC 10 ms
4,960 KB
testcase_28 AC 5 ms
4,348 KB
testcase_29 AC 3 ms
4,348 KB
testcase_30 AC 3 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
#include <set>
#include <queue>
#include <iomanip>
#include <cstring>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < int(n);i++)

int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  vector<int> a(n);
  for (int i = n-1;i >= 0;i--){
    if (i == n-1){
      if (s[i] == '#') a[i] = 1;
      else a[i] = 0;
    }
    else if (s[i] == '#'){
      a[i] = a[i+1]+2;
    }
    else{
      a[i] = a[i+1];
    }
  }
  int ans = 0;
  for (int i = 0; i < n;i++){
    if (s[i] == '#'){
      ans = max(ans,a[i]);
    }
  }
  cout << ans << endl;

  return 0;
}
0