結果
問題 | No.345 最小チワワ問題 |
ユーザー |
![]() |
提出日時 | 2019-06-15 22:17:38 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 527 bytes |
コンパイル時間 | 484 ms |
コンパイル使用メモリ | 63,000 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-21 06:42:52 |
合計ジャッジ時間 | 1,445 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 29 |
ソースコード
#include <iostream> #include <string> #include <vector> #include <algorithm> using namespace std; int main() { string s; vector<int> len; cin >> s; for (int i=0; i<s.size(); i++) { int flg=0; if (s[i]=='c') { for (int j=i+1; j<s.size(); j++) { if (s[j]=='w') flg++; if (flg==2) { len.push_back(j-i+1); break; } } } } if (len.size()==0) { printf("-1\n"); } else { printf("%d\n", *min_element(len.begin(), len.end())); } return 0; }