結果
問題 | No.345 最小チワワ問題 |
ユーザー |
![]() |
提出日時 | 2017-08-23 22:31:31 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 586 bytes |
コンパイル時間 | 477 ms |
コンパイル使用メモリ | 58,656 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-25 12:02:49 |
合計ジャッジ時間 | 1,460 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 29 |
ソースコード
#include <iostream> #include <algorithm> #include <string> using namespace std; int main() { string s; int ans = 101; cin >> s; for (size_t i = 0; i < s.length(); i++) { if (s[i] == 'c') { int tmp = 1, cnt = 1; for (size_t j = i + 1; j < s.length(); j++) { if (s[j] == 'w') { if (tmp == 1) { tmp = 2; cnt++; } else if (tmp == 2) { cnt++; ans = min(ans, cnt); } } else { cnt++; } } } } if (ans == 101) ans = -1; cout << ans << endl; }