結果
問題 |
No.345 最小チワワ問題
|
ユーザー |
|
提出日時 | 2018-01-01 18:29:28 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 528 bytes |
コンパイル時間 | 1,574 ms |
コンパイル使用メモリ | 170,156 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-12-22 23:46:33 |
合計ジャッジ時間 | 2,738 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 28 RE * 1 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define REP(i, n) for(int i = 0; i < n; i++) int main() { string s; cin >> s; vector<int> c, w; REP(i, s.length()) { if (s[i] == 'c') c.push_back(i); if (s[i] == 'w') w.push_back(i); } int ans = INT_MAX; REP(i, c.size()) { REP(j, w.size() - 1) { if (w[j] > c[i]) { ans = min(ans, w[j + 1] - c[i] + 1); } } } cout << ((ans == INT_MAX) ? -1 : ans) << endl; return 0; }