結果

問題 No.3044 April Sum of Odd
ユーザー severrabaenseverrabaen
提出日時 2019-04-01 21:19:15
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 37 ms / 2,000 ms
コード長 1,039 bytes
コンパイル時間 1,267 ms
コンパイル使用メモリ 148,564 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-17 13:52:13
合計ジャッジ時間 2,092 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

//↓template↓

#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
const long long INF = 1e18;
const long long MOD = 1e9 + 7;
const double pi = acos(-1);
const int SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
long long fac[200005], finv[200005], inv[200005];
vector<long long>dij;
struct edge { long long to, cost; };
vector<vector<edge> >G;

long long mod_pow(long long a, long long b) {
	long long res = 1;
	while (b) {
		if (b & 1) { res = res * a%MOD; }
		a = a * a%MOD;
		b >>= 1;
	}
	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

//↑template↑

int main() {
	long long a, b, k[100005], ans = 0, mon = 0;
	cin >> a >> b;
	for (int i = 0; i < a; ++i) {
		cin >> k[i];
		if (k[i] % 2 == 0 && ans != 0 && mon >= b) {
			cout << ans << endl;
			ans = 0;
			mon = 0;
		}
		else if (k[i] % 2 == 1) { ans += k[i]; ++mon; }
		else { mon = 0; ans = 0; }
	}
	if (ans != 0 && mon >= b) { cout << ans << endl; }
}
0