結果
問題 | No.204 ゴールデン・ウィーク(2) |
ユーザー | crazybbb3 |
提出日時 | 2017-01-16 23:07:07 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,375 bytes |
コンパイル時間 | 3,690 ms |
コンパイル使用メモリ | 80,700 KB |
実行使用メモリ | 54,064 KB |
最終ジャッジ日時 | 2023-08-24 13:40:16 |
合計ジャッジ時間 | 9,579 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 80 ms
52,848 KB |
testcase_01 | AC | 80 ms
52,828 KB |
testcase_02 | AC | 81 ms
53,276 KB |
testcase_03 | AC | 87 ms
53,232 KB |
testcase_04 | AC | 81 ms
52,984 KB |
testcase_05 | AC | 80 ms
53,660 KB |
testcase_06 | AC | 81 ms
53,276 KB |
testcase_07 | AC | 81 ms
52,932 KB |
testcase_08 | AC | 80 ms
52,980 KB |
testcase_09 | AC | 83 ms
53,052 KB |
testcase_10 | AC | 81 ms
52,816 KB |
testcase_11 | AC | 81 ms
52,972 KB |
testcase_12 | AC | 87 ms
53,156 KB |
testcase_13 | AC | 81 ms
53,232 KB |
testcase_14 | AC | 81 ms
53,008 KB |
testcase_15 | AC | 80 ms
52,848 KB |
testcase_16 | AC | 79 ms
52,936 KB |
testcase_17 | AC | 82 ms
53,044 KB |
testcase_18 | AC | 83 ms
52,956 KB |
testcase_19 | AC | 81 ms
53,040 KB |
testcase_20 | AC | 81 ms
52,700 KB |
testcase_21 | AC | 85 ms
52,792 KB |
testcase_22 | AC | 82 ms
53,224 KB |
testcase_23 | AC | 81 ms
53,320 KB |
testcase_24 | AC | 82 ms
54,064 KB |
testcase_25 | AC | 91 ms
52,940 KB |
testcase_26 | AC | 82 ms
53,012 KB |
testcase_27 | AC | 81 ms
52,816 KB |
testcase_28 | AC | 80 ms
52,804 KB |
testcase_29 | AC | 80 ms
52,688 KB |
testcase_30 | AC | 87 ms
52,904 KB |
testcase_31 | WA | - |
testcase_32 | AC | 80 ms
53,232 KB |
testcase_33 | AC | 81 ms
53,928 KB |
testcase_34 | AC | 81 ms
53,376 KB |
testcase_35 | AC | 81 ms
52,704 KB |
testcase_36 | AC | 81 ms
53,176 KB |
testcase_37 | AC | 81 ms
52,776 KB |
testcase_38 | AC | 81 ms
52,624 KB |
testcase_39 | AC | 82 ms
52,984 KB |
testcase_40 | AC | 82 ms
53,820 KB |
testcase_41 | AC | 90 ms
52,708 KB |
testcase_42 | AC | 91 ms
52,780 KB |
testcase_43 | AC | 81 ms
52,680 KB |
testcase_44 | AC | 81 ms
53,960 KB |
testcase_45 | AC | 81 ms
52,680 KB |
testcase_46 | AC | 80 ms
52,768 KB |
testcase_47 | AC | 80 ms
53,176 KB |
testcase_48 | AC | 89 ms
52,644 KB |
ソースコード
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.*; public class Main { void solve() throws IOException { int n = ni(); String t = "xxxxxxxxxxxxxx"; String s = t + ns() + ns() + t; ArrayList<Integer> list = new ArrayList<>(); int cnt = 1; for (int i = 0; i < s.length() - 1; i++) { if (s.charAt(i) == s.charAt(i + 1)) { cnt++; } else { list.add(cnt); cnt = 1; } } list.add(cnt); int ans = 0; for (int i = 1; i < list.size(); i += 2) { if (list.get(i - 1) >= n || list.get(i + 1) >= n) { ans = Math.max(ans, list.get(i) + n); } if (i != 1 && list.get(i - 1) <= n) { ans = Math.max(ans, list.get(i - 2) + list.get(i - 1) + list.get(i)); } } out.println(ans); } String ns() throws IOException { while (!tok.hasMoreTokens()) { tok = new StringTokenizer(in.readLine(), " "); } return tok.nextToken(); } int ni() throws IOException { return Integer.parseInt(ns()); } long nl() throws IOException { return Long.parseLong(ns()); } double nd() throws IOException { return Double.parseDouble(ns()); } String[] nsa(int n) throws IOException { String[] res = new String[n]; for (int i = 0; i < n; i++) { res[i] = ns(); } return res; } int[] nia(int n) throws IOException { int[] res = new int[n]; for (int i = 0; i < n; i++) { res[i] = ni(); } return res; } long[] nla(int n) throws IOException { long[] res = new long[n]; for (int i = 0; i < n; i++) { res[i] = nl(); } return res; } static BufferedReader in; static PrintWriter out; static StringTokenizer tok; public static void main(String[] args) throws IOException { in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); tok = new StringTokenizer(""); Main main = new Main(); main.solve(); out.close(); } }