結果

問題 No.346 チワワ数え上げ問題
ユーザー BantakoBantako
提出日時 2017-07-16 21:10:38
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 456 bytes
コンパイル時間 132 ms
コンパイル使用メモリ 22,400 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-16 22:37:23
合計ジャッジ時間 818 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 0 ms
5,376 KB
testcase_06 AC 0 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 1 ms
5,376 KB
testcase_12 AC 1 ms
5,376 KB
testcase_13 AC 1 ms
5,376 KB
testcase_14 AC 0 ms
5,376 KB
testcase_15 AC 1 ms
5,376 KB
testcase_16 AC 1 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 1 ms
5,376 KB
testcase_19 AC 1 ms
5,376 KB
testcase_20 AC 1 ms
5,376 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 0 ms
5,376 KB
testcase_24 AC 0 ms
5,376 KB
testcase_25 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:3:1: warning: ISO C++ forbids declaration of ‘main’ with no type [-Wreturn-type]
    3 | main(){
      | ^~~~

ソースコード

diff #

#include<stdio.h>
int num[100000];
main(){
    int sum = 0;
    char c;
    int count = 0;//cの数
    while((c=getchar())!='\n' && c!=' '){
        if(c=='c'){
            num[count] = sum;
            count++;
        }
        if(c=='w'){
            sum++;
        }
    }
    long long ans = 0;
    for(int i = 0;i < count;i++){
        int a = sum-num[i];
        if(a >= 2){
            ans += a*(a-1)/2;
        }
    }
    printf("%lld\n",ans);
}
0