結果
問題 |
No.805 UMG
|
ユーザー |
|
提出日時 | 2019-04-26 17:07:52 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 172 ms / 2,000 ms |
コード長 | 747 bytes |
コンパイル時間 | 3,262 ms |
コンパイル使用メモリ | 75,324 KB |
実行使用メモリ | 41,556 KB |
最終ジャッジ日時 | 2024-11-18 13:46:30 |
合計ジャッジ時間 | 8,019 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 25 |
ソースコード
import java.io.*; import java.util.Scanner; public class Main_yukicoder805 { private static Scanner sc; private static Printer pr; private static void solve() { int n = sc.nextInt(); char[] s = sc.next().toCharArray(); int ans = 0; for (int i = 0; i < n; i++) { for (int j = 1; i + j + j < n; j++) { if (s[i] == 'U' && s[i + j] == 'M' && s[i + j + j] == 'G') { ans++; } } } pr.println(ans); } // --------------------------------------------------- public static void main(String[] args) { sc = new Scanner(System.in); pr = new Printer(System.out); solve(); pr.close(); sc.close(); } static class Printer extends PrintWriter { Printer(OutputStream out) { super(out); } } }