結果

問題 No.345 最小チワワ問題
ユーザー かぼちゃ
提出日時 2018-03-28 17:21:05
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 747 bytes
コンパイル時間 577 ms
コンパイル使用メモリ 66,500 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-06-25 13:12:50
合計ジャッジ時間 1,556 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 WA * 1
other AC * 11 WA * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    string s;
    cin >> s;
    vector<int> ans;
    for(int i = 0;i < s.length();i++){
        if(s[i] == 'c'){
            int tester = 1;
            bool flag = false;
            for(int j = i + 1;j < s.length();j++){
                tester++;
                if(!flag && s[j] == 'w'){
                flag = true;
                }
                else if(flag && s[j] == 'w'){
                    break;
                }
            }
            ans.push_back(tester);
        }
    }
    sort(ans.begin(), ans.end(),greater<int>());
    if(ans.size() == 0)cout << -1 << endl;
    else cout << ans[0] << endl;
    return 0;
}
0