結果
問題 | No.345 最小チワワ問題 |
ユーザー |
![]() |
提出日時 | 2018-01-17 19:34:07 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 543 bytes |
コンパイル時間 | 679 ms |
コンパイル使用メモリ | 59,712 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-25 12:08:48 |
合計ジャッジ時間 | 1,778 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 29 |
ソースコード
#include<iostream> #include<vector> #include<string> #include<cstdio> #include<algorithm> using namespace std; int main(){ string str; int ans=100000,count; cin >> str; for(int i=0;str[i]!='\0';i++){ if(str[i]=='c'){ count =0; for(int j=i;str[j]!='\0';j++){ if(str[j]=='w'){ count++; } if(count==2) ans = min(ans,j-i+1); } } } if(ans==100000) cout << "-1"; else cout << ans; return 0; }