結果
問題 | No.436 ccw |
ユーザー |
![]() |
提出日時 | 2016-11-25 15:55:21 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 207 ms / 2,000 ms |
コード長 | 455 bytes |
コンパイル時間 | 3,136 ms |
コンパイル使用メモリ | 74,348 KB |
実行使用メモリ | 42,588 KB |
最終ジャッジ日時 | 2024-11-27 11:15:50 |
合計ジャッジ時間 | 7,733 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 24 |
ソースコード
import java.util.*; import java.util.regex.*; public class A{ public static void main(String args[]){ Scanner sc=new Scanner(System.in); String s=sc.next(); int c=a(s,"c"); int w=a(s,"w"); if(c>=w+1){ System.out.print(w); }else{ System.out.print(c-1); } } public static int a(String s,String c){ int count=0; Pattern p = Pattern.compile(c); Matcher m = p.matcher(s); while(m.find()){ count++; } return count; } }