結果

問題 No.3044 April Sum of Odd
ユーザー kyo1kyo1
提出日時 2020-06-01 07:55:50
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 469 bytes
コンパイル時間 2,209 ms
コンパイル使用メモリ 200,460 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-13 06:46:24
合計ジャッジ時間 3,683 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, M;
  cin >> N >> M;
  vector<int64_t> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  int64_t sum = 0;
  for (int i = 0; i < N; i++) {
    if (A[i] % 2 == 0) continue;
    int cnt = 1;
    while (i < N && A[i] % 2 != 0) {
      sum += A[i];
      i++;
      cnt++;
    }
    if (cnt >= M) cout << sum << '\n';
    sum = 0;
  }
  return 0;
}
0