結果

問題 No.2035 Tunnel
ユーザー tentententen
提出日時 2023-01-19 07:55:05
言語 Java21
(openjdk 21)
結果
AC  
実行時間 123 ms / 2,000 ms
コード長 1,848 bytes
コンパイル時間 4,179 ms
コンパイル使用メモリ 87,620 KB
実行使用メモリ 54,608 KB
最終ジャッジ日時 2023-09-03 14:54:45
合計ジャッジ時間 9,380 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
49,340 KB
testcase_01 AC 44 ms
49,552 KB
testcase_02 AC 44 ms
49,416 KB
testcase_03 AC 44 ms
49,684 KB
testcase_04 AC 44 ms
49,308 KB
testcase_05 AC 123 ms
54,380 KB
testcase_06 AC 121 ms
54,320 KB
testcase_07 AC 119 ms
54,428 KB
testcase_08 AC 114 ms
54,608 KB
testcase_09 AC 113 ms
54,172 KB
testcase_10 AC 122 ms
54,544 KB
testcase_11 AC 102 ms
52,776 KB
testcase_12 AC 119 ms
54,384 KB
testcase_13 AC 54 ms
49,924 KB
testcase_14 AC 76 ms
51,616 KB
testcase_15 AC 115 ms
52,324 KB
testcase_16 AC 107 ms
50,520 KB
testcase_17 AC 46 ms
49,332 KB
testcase_18 AC 54 ms
49,400 KB
testcase_19 AC 79 ms
51,596 KB
testcase_20 AC 114 ms
52,132 KB
testcase_21 AC 96 ms
52,164 KB
testcase_22 AC 96 ms
52,040 KB
testcase_23 AC 57 ms
49,936 KB
testcase_24 AC 105 ms
52,388 KB
testcase_25 AC 106 ms
52,348 KB
testcase_26 AC 106 ms
52,704 KB
testcase_27 AC 121 ms
54,524 KB
testcase_28 AC 101 ms
52,004 KB
testcase_29 AC 58 ms
49,596 KB
testcase_30 AC 55 ms
47,380 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 right = n - 1;
        int current = -1;
        while (right >= 0) {
            while (right >= 0 && inputs[right] == '.') {
                right--;
            }
            if (right >= 0) {
                current = Math.max(current + 2, n - right);
                right--;
            }
        }
        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