結果

問題 No.3044 April Sum of Odd
ユーザー yuruhiyayuruhiya
提出日時 2019-04-01 21:28:10
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 37 ms / 2,000 ms
コード長 945 bytes
コンパイル時間 1,531 ms
コンパイル使用メモリ 167,136 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-17 14:12:09
合計ジャッジ時間 2,279 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define Cout2(x, y) cout << (x) << " " << (y) << endl
#define dump(x) cerr << #x << " = " << (x) << endl;
typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = 1e9;
const double pi = acos(-1.0);

int main() {
	LL n, m; cin >> n >> m;
	VL a(n); rep(i, n)cin >> a[i];

	LL sum = 0, cnt = 0, i = 0;
	while (i < n) {
		if (a[i] % 2 == 1) {
			while (i < n&&a[i] % 2 == 1) {
				sum += a[i]; cnt++;
				i++;
			}
			if (cnt >= m)Cout(sum);
		}
		else {
			i++;
			cnt = 0; sum = 0;
		}
	}
}
0