結果
| 問題 | 
                            No.346 チワワ数え上げ問題
                             | 
                    
| コンテスト | |
| ユーザー | 
                             Bantako
                         | 
                    
| 提出日時 | 2017-07-16 21:10:38 | 
| 言語 | C++11(廃止可能性あり)  (gcc 13.3.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 456 bytes | 
| コンパイル時間 | 124 ms | 
| コンパイル使用メモリ | 22,016 KB | 
| 実行使用メモリ | 5,248 KB | 
| 最終ジャッジ日時 | 2024-10-08 04:30:23 | 
| 合計ジャッジ時間 | 946 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge2 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 21 WA * 2 | 
コンパイルメッセージ
main.cpp:3:1: warning: ISO C++ forbids declaration of ‘main’ with no type [-Wreturn-type]
    3 | main(){
      | ^~~~
            
            ソースコード
#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);
}
            
            
            
        
            
Bantako