結果

問題 No.3044 April Sum of Odd
ユーザー hamrayhamray
提出日時 2019-04-01 21:37:49
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 740 bytes
コンパイル時間 652 ms
コンパイル使用メモリ 79,848 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-05 04:08:42
合計ジャッジ時間 1,345 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 4 ms
5,376 KB
testcase_04 WA -
testcase_05 AC 5 ms
5,376 KB
testcase_06 AC 7 ms
5,376 KB
testcase_07 AC 3 ms
5,376 KB
testcase_08 AC 4 ms
5,376 KB
testcase_09 AC 6 ms
5,376 KB
testcase_10 AC 39 ms
5,376 KB
testcase_11 AC 18 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <map>
#include <algorithm>
#include <iomanip>
#include <cmath>
using namespace std;

#define MAXV 1000000000
#define MOD 1000000007
using ll = long long;

bool operator<(const pair<int, int>& a, const pair<int, int>& b) {
	if (a.first == b.first) {
		return a.second < b.second;
	}
	return a.first < b.first;
}
ll a[100010];
int main() {
	
	ll N, M; cin >> N >> M;
	for (int i = 0; i < N;++i) cin >> a[i];

	ll cnt = 0;
	ll sum = 0;
	for (int i = 0;i < N; ++i) {
		if (a[i] % 2 == 1) {
			cnt++;
			sum += a[i];
		}
		else {
			if (cnt >= M) {
				cout << sum << endl;
				
			}cnt = 0;
			sum = 0;
		}
	}
	if (sum) cout << sum << endl;
	int aa; cin >> aa;
}
0