結果
問題 |
No.805 UMG
|
ユーザー |
![]() |
提出日時 | 2019-11-11 19:00:49 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 159 ms / 2,000 ms |
コード長 | 519 bytes |
コンパイル時間 | 2,079 ms |
コンパイル使用メモリ | 74,296 KB |
実行使用メモリ | 54,420 KB |
最終ジャッジ日時 | 2024-11-18 13:54:50 |
合計ジャッジ時間 | 6,358 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 25 |
ソースコード
import java.util.*; public class Main { static TreeSet<Integer> primes; public static void main (String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); char[] arr = sc.next().toCharArray(); int count = 0; for (int i = 0; i < n; i++) { if (arr[i] != 'U') { continue; } for (int j = 1; i + j * 2 < n; j++) { if (arr[i + j] == 'M' && arr[i + j * 2] == 'G') { count++; } } } System.out.println(count); } }