結果

問題 No.805 UMG
ユーザー harhogefooharhogefoo
提出日時 2019-04-07 23:52:12
言語 PHP
(8.3.4)
結果
AC  
実行時間 449 ms / 2,000 ms
コード長 481 bytes
コンパイル時間 1,827 ms
コンパイル使用メモリ 30,744 KB
実行使用メモリ 31,204 KB
最終ジャッジ日時 2024-04-29 10:52:15
合計ジャッジ時間 5,920 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
31,096 KB
testcase_01 AC 40 ms
30,952 KB
testcase_02 AC 39 ms
31,156 KB
testcase_03 AC 40 ms
30,848 KB
testcase_04 AC 40 ms
30,748 KB
testcase_05 AC 40 ms
31,128 KB
testcase_06 AC 40 ms
30,752 KB
testcase_07 AC 40 ms
31,148 KB
testcase_08 AC 40 ms
31,116 KB
testcase_09 AC 40 ms
31,076 KB
testcase_10 AC 40 ms
30,892 KB
testcase_11 AC 41 ms
30,776 KB
testcase_12 AC 39 ms
30,976 KB
testcase_13 AC 42 ms
30,824 KB
testcase_14 AC 40 ms
31,064 KB
testcase_15 AC 52 ms
31,048 KB
testcase_16 AC 50 ms
30,672 KB
testcase_17 AC 48 ms
31,012 KB
testcase_18 AC 54 ms
30,820 KB
testcase_19 AC 45 ms
31,060 KB
testcase_20 AC 56 ms
31,040 KB
testcase_21 AC 49 ms
31,148 KB
testcase_22 AC 50 ms
31,204 KB
testcase_23 AC 423 ms
30,784 KB
testcase_24 AC 434 ms
30,860 KB
testcase_25 AC 449 ms
30,992 KB
testcase_26 AC 439 ms
31,172 KB
testcase_27 AC 446 ms
30,932 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
No syntax errors detected in Main.php

ソースコード

diff #

<?php
  $N = trim(fgets(STDIN));
  list($S) = explode(" ", trim(fgets(STDIN)));

  $count = 0;
  for($i = 1; $i <= $N; $i++) {
    if (strcmp($S[$i - 1], "U") != 0) {
      continue;
    }

    for($j = $i + 1; $j <= $N; $j++) {
      if (strcmp($S[$j - 1], "M") != 0) {
        continue;
      }
      $k = $j * 2 - $i;
      if ($N < $k) {
        continue;
      }
      if (strcmp($S[$k - 1], "G") != 0) {
        continue;
      }
      $count++;
    }
  }
  printf("$count");
0