結果

問題 No.805 UMG
ユーザー tsunabittsunabit
提出日時 2019-07-13 20:35:19
言語 Java21
(openjdk 21)
結果
AC  
実行時間 206 ms / 2,000 ms
コード長 613 bytes
コンパイル時間 3,522 ms
コンパイル使用メモリ 75,116 KB
実行使用メモリ 41,480 KB
最終ジャッジ日時 2024-04-29 10:58:32
合計ジャッジ時間 8,431 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 120 ms
40,188 KB
testcase_01 AC 120 ms
39,832 KB
testcase_02 AC 128 ms
40,956 KB
testcase_03 AC 133 ms
41,104 KB
testcase_04 AC 131 ms
41,072 KB
testcase_05 AC 132 ms
41,192 KB
testcase_06 AC 131 ms
41,200 KB
testcase_07 AC 131 ms
41,424 KB
testcase_08 AC 120 ms
40,376 KB
testcase_09 AC 132 ms
41,368 KB
testcase_10 AC 118 ms
39,972 KB
testcase_11 AC 131 ms
41,328 KB
testcase_12 AC 133 ms
41,200 KB
testcase_13 AC 132 ms
41,140 KB
testcase_14 AC 130 ms
41,008 KB
testcase_15 AC 141 ms
41,372 KB
testcase_16 AC 143 ms
41,092 KB
testcase_17 AC 140 ms
41,452 KB
testcase_18 AC 147 ms
41,380 KB
testcase_19 AC 142 ms
41,376 KB
testcase_20 AC 142 ms
41,340 KB
testcase_21 AC 139 ms
41,244 KB
testcase_22 AC 141 ms
41,480 KB
testcase_23 AC 201 ms
41,132 KB
testcase_24 AC 192 ms
40,644 KB
testcase_25 AC 202 ms
41,348 KB
testcase_26 AC 201 ms
41,260 KB
testcase_27 AC 206 ms
41,056 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