結果

問題 No.805 UMG
ユーザー michonz4
提出日時 2019-12-30 09:07:48
言語 C
(gcc 13.3.0)
結果
AC  
実行時間 21 ms / 2,000 ms
コード長 319 bytes
コンパイル時間 192 ms
コンパイル使用メモリ 29,440 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-18 13:55:50
合計ジャッジ時間 974 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>

int main() {
  int n, cnt=0;
  char s[5001];
  scanf("%d %s", &n, s);

  for (int i=0; i<n-2; i++) {
    int by=1;
    for (int j=i+by; j<n-by; j++) {
      
      if (s[i]=='U' && s[j]=='M' && s[j+by]=='G') {
        cnt++;
      }
      
      by++;
    }
  }

  printf("%d\n", cnt);
  return 0;
}
0