結果

問題 No.805 UMG
ユーザー tsunabittsunabit
提出日時 2019-07-13 20:35:19
言語 Java21
(openjdk 21)
結果
AC  
実行時間 195 ms / 2,000 ms
コード長 613 bytes
コンパイル時間 3,597 ms
コンパイル使用メモリ 72,460 KB
実行使用メモリ 56,432 KB
最終ジャッジ日時 2023-08-11 19:40:24
合計ジャッジ時間 8,604 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
56,120 KB
testcase_01 AC 127 ms
56,112 KB
testcase_02 AC 122 ms
55,604 KB
testcase_03 AC 123 ms
55,768 KB
testcase_04 AC 121 ms
55,640 KB
testcase_05 AC 124 ms
55,720 KB
testcase_06 AC 123 ms
55,948 KB
testcase_07 AC 124 ms
55,904 KB
testcase_08 AC 124 ms
55,608 KB
testcase_09 AC 119 ms
56,432 KB
testcase_10 AC 121 ms
55,688 KB
testcase_11 AC 120 ms
55,388 KB
testcase_12 AC 122 ms
55,584 KB
testcase_13 AC 124 ms
55,856 KB
testcase_14 AC 125 ms
55,564 KB
testcase_15 AC 137 ms
55,408 KB
testcase_16 AC 133 ms
55,624 KB
testcase_17 AC 133 ms
56,004 KB
testcase_18 AC 132 ms
55,768 KB
testcase_19 AC 136 ms
55,752 KB
testcase_20 AC 135 ms
55,848 KB
testcase_21 AC 134 ms
55,604 KB
testcase_22 AC 132 ms
55,752 KB
testcase_23 AC 195 ms
55,744 KB
testcase_24 AC 190 ms
55,696 KB
testcase_25 AC 191 ms
55,728 KB
testcase_26 AC 187 ms
55,592 KB
testcase_27 AC 188 ms
55,988 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.io.*;
import java.math.*;

public class No805 {
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int n = sc.nextInt();
    	String s = sc.next();
    	char[] as = new char[n];
    	
    	for(int i = 0; i < n; i++) {
    		as[i] = s.charAt(i);
    	}
    	int c = 0;
    	for(int i = 0; i < n; i++) {
    		for(int k = n-1; k > i; k--) {
    			double j = ((i+k)/2.0);
    			if((i+k)%2 == 0 && (j-i) == (k-j) && as[i] == 'U' && as[(int)j] == 'M' && as[k] == 'G') {
    				c++;
    			}
    		}
    	}
    	System.out.println(c);
    }
}
0