結果

問題 No.3044 April Sum of Odd
ユーザー eto_nagisaeto_nagisa
提出日時 2019-04-01 21:45:10
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 14 ms / 2,000 ms
コード長 1,332 bytes
コンパイル時間 1,628 ms
コンパイル使用メモリ 169,168 KB
実行使用メモリ 5,056 KB
最終ジャッジ日時 2023-08-17 21:36:55
合計ジャッジ時間 2,330 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

constexpr int dx[8] = { 1,1,0,-1,-1,-1,0,1 };
constexpr int dy[8] = { 0,1,1,1,0,-1,-1,-1 };


using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m; cin >> n >> m;
	vl v(n);
	REP(i, n)cin >> v[i];
	vl tmp;
	vl ans;
	REP(i, n) {
		if (v[i] % 2 == 0) {
			if (tmp.size() >= m) {
				ll sum = 0;
				REP(j, tmp.size())sum += tmp[j];
				ans.push_back(sum);
			}
			tmp.clear();
		}
		else {
			tmp.push_back(v[i]);
		}
	}
	if (tmp.size() >= m) {
		ll sum = 0;
		REP(j, tmp.size())sum += tmp[j];
		ans.push_back(sum);
	}
	tmp.clear();
	REP(i, ans.size())cout << ans[i] << endl;
}
0