結果
問題 | No.204 ゴールデン・ウィーク(2) |
ユーザー | 37zigen |
提出日時 | 2020-03-19 01:03:43 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 854 bytes |
コンパイル時間 | 2,290 ms |
コンパイル使用メモリ | 85,620 KB |
実行使用メモリ | 41,584 KB |
最終ジャッジ日時 | 2024-05-08 02:58:10 |
合計ジャッジ時間 | 9,644 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 118 ms
41,444 KB |
testcase_01 | WA | - |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | AC | 112 ms
40,220 KB |
testcase_05 | AC | 114 ms
40,288 KB |
testcase_06 | AC | 127 ms
41,584 KB |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
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 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | AC | 114 ms
40,292 KB |
testcase_26 | AC | 125 ms
41,184 KB |
testcase_27 | AC | 128 ms
41,552 KB |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | AC | 126 ms
41,352 KB |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | AC | 124 ms
41,292 KB |
testcase_35 | AC | 129 ms
41,160 KB |
testcase_36 | AC | 127 ms
41,484 KB |
testcase_37 | WA | - |
testcase_38 | WA | - |
testcase_39 | WA | - |
testcase_40 | WA | - |
testcase_41 | AC | 122 ms
41,072 KB |
testcase_42 | WA | - |
testcase_43 | WA | - |
testcase_44 | AC | 124 ms
41,532 KB |
testcase_45 | AC | 123 ms
41,256 KB |
testcase_46 | WA | - |
testcase_47 | WA | - |
testcase_48 | AC | 114 ms
40,192 KB |
ソースコード
import java.util.ArrayDeque; import java.util.Arrays; import java.util.Scanner; class Main { public static void main(String[] args) { new Main().run(); } void run() { Scanner sc = new Scanner(System.in); int D=sc.nextInt(); char[] cs=(sc.next()+sc.next()).toCharArray(); int[] a=new int[cs.length]; int p=0; for(int i=0;i<cs.length;++i) { int j=i; while(j+1<cs.length&&cs[i]==cs[j+1])++j; a[p++]=j-i+1; i=j; } int cur=cs[0]=='x'?0:1;//x:平日 int ans=0; for(int i=0;i<p;++i) { if(i%2==cur) { ans=Math.max(ans, (a[i]>=D&&i>0?a[i-1]:0)+Math.min(a[i],D)+(i+1<a.length?a[i+1]:0)); }else { ans=Math.max(ans, a[i]+(i+1<a.length?(Math.min(a[i+1],D)+(i+2<a.length?a[i+2]:0)):0)); } } System.out.println(ans); } void tr(Object... objects) { System.out.println(Arrays.deepToString(objects)); } }