結果

問題 No.3044 April Sum of Odd
ユーザー jupiro_jupijupiro_jupi
提出日時 2019-04-01 21:24:33
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 36 ms / 2,000 ms
コード長 980 bytes
コンパイル時間 734 ms
コンパイル使用メモリ 82,860 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-17 14:04:05
合計ジャッジ時間 1,501 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

char ToUpper(char cX) { return toupper(cX); }
char Tolower(char cX) { return tolower(cX); }

const long long INF = 1LL << 60;
const long long MOD = 1000000007;

using namespace std;
typedef unsigned long long ull;
typedef  long long ll;

vector<ll> dp;


int main()
{
	ll n, m;
	cin >> n >> m;
	ll sum = 0;
	ll flag = 0;
	for (ll i = 0; i < n; i++) {
		ll temp;
		cin >> temp;
		if (temp % 2 == 1) {
			flag++;
			sum += temp;
		}
		else {
			if (flag >= m) {
				cout << sum << endl;
			}
			flag = 0;
			sum = 0;
		}
	}
	if (flag >= m) {
		cout << sum << endl;
	}
	return 0;
}
0