結果
問題 |
No.346 チワワ数え上げ問題
|
ユーザー |
![]() |
提出日時 | 2017-07-16 21:08:23 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 446 bytes |
コンパイル時間 | 217 ms |
コンパイル使用メモリ | 22,016 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-08 04:30:17 |
合計ジャッジ時間 | 1,521 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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'){ 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); }