結果

問題 No.2035 Tunnel
ユーザー tentententen
提出日時 2023-07-25 08:38:29
言語 Java21
(openjdk 21)
結果
AC  
実行時間 118 ms / 2,000 ms
コード長 1,715 bytes
コンパイル時間 2,355 ms
コンパイル使用メモリ 83,980 KB
実行使用メモリ 54,432 KB
最終ジャッジ日時 2024-04-10 01:57:47
合計ジャッジ時間 6,348 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 52 ms
50,040 KB
testcase_01 AC 52 ms
50,040 KB
testcase_02 AC 51 ms
50,432 KB
testcase_03 AC 50 ms
50,168 KB
testcase_04 AC 51 ms
50,116 KB
testcase_05 AC 116 ms
54,364 KB
testcase_06 AC 117 ms
53,904 KB
testcase_07 AC 118 ms
54,376 KB
testcase_08 AC 117 ms
54,432 KB
testcase_09 AC 109 ms
53,908 KB
testcase_10 AC 117 ms
54,028 KB
testcase_11 AC 109 ms
52,356 KB
testcase_12 AC 107 ms
54,232 KB
testcase_13 AC 64 ms
50,924 KB
testcase_14 AC 74 ms
51,304 KB
testcase_15 AC 114 ms
52,316 KB
testcase_16 AC 107 ms
52,316 KB
testcase_17 AC 53 ms
50,396 KB
testcase_18 AC 57 ms
50,380 KB
testcase_19 AC 82 ms
51,428 KB
testcase_20 AC 113 ms
52,508 KB
testcase_21 AC 89 ms
51,980 KB
testcase_22 AC 86 ms
51,756 KB
testcase_23 AC 68 ms
50,716 KB
testcase_24 AC 107 ms
52,128 KB
testcase_25 AC 106 ms
52,196 KB
testcase_26 AC 107 ms
51,920 KB
testcase_27 AC 117 ms
54,228 KB
testcase_28 AC 90 ms
52,012 KB
testcase_29 AC 64 ms
50,740 KB
testcase_30 AC 62 ms
50,636 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;
import java.util.stream.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        int n = sc.nextInt();
        char[] inputs = sc.next().toCharArray();
        int current = -1;
        for (int i = n - 1; i >= 0; i--) {
            if (inputs[i] == '#') {
                current = Math.max(n - i, current + 2);
            }
        }
        System.out.println(current);
    }
}
class Utilities {
    static String arrayToLineString(Object[] arr) {
        return Arrays.stream(arr).map(x -> x.toString()).collect(Collectors.joining("\n"));
    }
    
    static String arrayToLineString(int[] arr) {
        return String.join("\n", Arrays.stream(arr).mapToObj(String::valueOf).toArray(String[]::new));
    }
}
class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    StringBuilder sb = new StringBuilder();
    
    public Scanner() throws Exception {
        
    }
    
    public int nextInt() throws Exception {
        return Integer.parseInt(next());
    }
    
    public long nextLong() throws Exception {
        return Long.parseLong(next());
    }
    
    public double nextDouble() throws Exception {
        return Double.parseDouble(next());
    }
    
    public int[] nextIntArray() throws Exception {
        return Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
    }
    
    public String next() throws Exception {
        while (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
    
}
0