結果
問題 |
No.345 最小チワワ問題
|
ユーザー |
![]() |
提出日時 | 2018-08-27 12:51:56 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 680 bytes |
コンパイル時間 | 484 ms |
コンパイル使用メモリ | 60,064 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-01 05:08:14 |
合計ジャッジ時間 | 1,409 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 29 |
ソースコード
#include <iostream> #include <string> #include <cmath> using namespace std; int main() { string s; cin >> s; float ans = INFINITY; for(int i = 0; i < s.length(); i++){ if(s[i] == 'c'){ int cou = 0; int flag = 0; for(int j = i; j < s.length(); j++){ cou++; if(s[j] == 'w') flag++; if(flag == 2){ if(cou >= 3 && cou < ans) ans = cou; break; } } } } if(ans == INFINITY) cout << -1 << endl; else cout << ans << endl; return 0; }