結果

問題 No.8044 April Sum of Odd
ユーザー leaf_1415
提出日時 2019-04-01 21:18:48
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 39 ms / 2,000 ms
コード長 414 bytes
コンパイル時間 418 ms
コンパイル使用メモリ 55,344 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-26 10:42:13
合計ジャッジ時間 952 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#define llint long long

using namespace std;

llint n, m;
llint a[100005];

int main(void)
{
	cin >> n >> m;
	for(int i = 1; i <= n; i++) cin >> a[i];
	
	llint cnt = 0, sum = 0;
	for(int i = 1; i <= n; i++){
		if(a[i]%2){
			cnt++;
			sum += a[i];
		}
		else{
			if(cnt >= m) cout << sum << endl;
			cnt = sum = 0;
		}
	}
	if(cnt >= m){
		cout << sum << endl;
	}
	return 0;
}
0