結果
問題 |
No.805 UMG
|
ユーザー |
![]() |
提出日時 | 2019-07-19 12:21:27 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 14 ms / 2,000 ms |
コード長 | 400 bytes |
コンパイル時間 | 568 ms |
コンパイル使用メモリ | 69,124 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-18 13:51:41 |
合計ジャッジ時間 | 1,420 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 25 |
ソースコード
#include <algorithm> #include <iostream> #include <vector> using namespace std; int main() { int n; cin >> n; string s; cin >> s; int cnt = 0; for (int i = 0; i < n; i++) if (s[i] == 'M') { int rng = min(i, n - i - 1); for (int k = 1; k <= rng; k++) { if (s[i - k] == 'U' && s[i + k] == 'G') cnt++; } } cout << cnt << endl; return 0; }