結果
問題 | No.203 ゴールデン・ウィーク(1) |
ユーザー |
![]() |
提出日時 | 2015-12-25 01:00:49 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 125 ms / 1,000 ms |
コード長 | 938 bytes |
コンパイル時間 | 3,302 ms |
コンパイル使用メモリ | 81,796 KB |
実行使用メモリ | 54,212 KB |
最終ジャッジ日時 | 2024-11-18 09:38:40 |
合計ジャッジ時間 | 7,643 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 29 |
ソースコード
public class No_203 { //休日の数を数える static int holiday(StringBuffer w, int c) { c++; if (c >= w.length() || !(w.charAt(c) == 'o')) { return c; } return holiday(w, c); } //平日の数を数える static int weekday(StringBuffer w, int c) { c++; if (c >= w.length() || !(w.charAt(c) == 'x')) { return c; } return weekday(w, c); } public static void main(String[] args) { java.util.Scanner sc = new java.util.Scanner(System.in); String s = sc.next() + sc.next(); StringBuffer week = new StringBuffer(s); int count = 0, max = 0; while (!week.toString().isEmpty()) {//文字列が無くなったら終わり if (week.charAt(0) == 'o') { count = holiday(week, 0); week.delete(0, count);//count分削除 max = Math.max(max, count); } else { count = weekday(week, 0); week.delete(0, count);//count分削除 } } System.out.println(max); sc.close(); } }