結果

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

ソースコード

diff #

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

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