結果

問題 No.805 UMG
ユーザー Beat7501Beat7501
提出日時 2019-03-22 21:34:04
言語 Java21
(openjdk 21)
結果
AC  
実行時間 283 ms / 2,000 ms
コード長 489 bytes
コンパイル時間 3,972 ms
コンパイル使用メモリ 71,252 KB
実行使用メモリ 59,952 KB
最終ジャッジ日時 2023-08-11 19:10:32
合計ジャッジ時間 8,227 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 120 ms
55,672 KB
testcase_01 AC 121 ms
55,432 KB
testcase_02 AC 119 ms
55,908 KB
testcase_03 AC 119 ms
56,068 KB
testcase_04 AC 118 ms
56,044 KB
testcase_05 AC 122 ms
56,148 KB
testcase_06 AC 119 ms
55,500 KB
testcase_07 AC 119 ms
55,932 KB
testcase_08 AC 122 ms
55,468 KB
testcase_09 AC 119 ms
55,692 KB
testcase_10 AC 118 ms
55,676 KB
testcase_11 AC 119 ms
55,620 KB
testcase_12 AC 119 ms
55,692 KB
testcase_13 AC 121 ms
55,636 KB
testcase_14 AC 119 ms
55,744 KB
testcase_15 AC 137 ms
57,852 KB
testcase_16 AC 137 ms
58,316 KB
testcase_17 AC 133 ms
58,112 KB
testcase_18 AC 140 ms
58,180 KB
testcase_19 AC 132 ms
59,544 KB
testcase_20 AC 138 ms
58,476 KB
testcase_21 AC 134 ms
57,724 KB
testcase_22 AC 136 ms
57,912 KB
testcase_23 AC 283 ms
59,852 KB
testcase_24 AC 256 ms
59,952 KB
testcase_25 AC 256 ms
59,464 KB
testcase_26 AC 260 ms
59,676 KB
testcase_27 AC 261 ms
59,884 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s = sc.next();
		String[] su = {"U","M","G"};
		int ans = 0;
		for(int i = 0; i < n; i++){
			if(su[0].equals(s.substring(i,i+1))){
				for(int j = 1; i+j*2 < n; j++){
					if(su[1].equals(s.substring(i+j,i+j+1))){
						if(su[2].equals(s.substring(i+j*2,i+j*2+1))){
							ans++;
						}
					}
				}
			}
		}
		System.out.println(ans);
	}
}
0