結果
問題 | No.346 チワワ数え上げ問題 |
ユーザー |
![]() |
提出日時 | 2020-11-18 15:15:21 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 5 ms / 2,000 ms |
コード長 | 302 bytes |
コンパイル時間 | 568 ms |
コンパイル使用メモリ | 65,772 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-23 09:02:17 |
合計ジャッジ時間 | 1,874 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 23 |
ソースコード
#include <iostream> #include <string> using namespace std; int main(){ string S; cin >> S; int N = S.size(); long long cnt = 0; long long ans = 0; for (int i = N - 1; i >= 0; i--){ if (S[i] == 'w'){ cnt++; } if (S[i] == 'c'){ ans += cnt * (cnt - 1) / 2; } } cout << ans << endl; }