結果
| 問題 |
No.346 チワワ数え上げ問題
|
| コンテスト | |
| ユーザー |
data9824
|
| 提出日時 | 2016-04-07 00:33:42 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 4 ms / 2,000 ms |
| コード長 | 344 bytes |
| コンパイル時間 | 573 ms |
| コンパイル使用メモリ | 55,004 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-04 02:24:40 |
| 合計ジャッジ時間 | 1,210 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 23 |
ソースコード
#include <iostream>
#include <string>
using namespace std;
int main() {
string s;
cin >> s;
long long wCount = 0;
long long result = 0;
for (int i = s.size() - 1; i >= 0; --i) {
if (s[i] == 'w') {
++wCount;
}
if (s[i] == 'c' && wCount >= 2) {
result += wCount * (wCount - 1) / 2;
}
}
cout << result << endl;
return 0;
}
data9824