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