結果
問題 |
No.8044 April Sum of Odd
|
ユーザー |
![]() |
提出日時 | 2024-11-01 01:02:32 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 39 ms / 2,000 ms |
コード長 | 682 bytes |
コンパイル時間 | 3,889 ms |
コンパイル使用メモリ | 253,624 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-01 01:02:38 |
合計ジャッジ時間 | 4,790 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 10 |
ソースコード
#include <bits/stdc++.h> using namespace std; #ifdef LOCAL #include "settings/debug.cpp" #else #define Debug(...) void(0) #endif #define rep(i, n) for (int i = 0; i < (n); ++i) using ll = long long; using ull = unsigned long long; int main() { int n, m; cin >> n >> m; vector<int> a(n); rep(i, n) cin >> a[i]; vector<tuple<int, int, ll>> rle(1, { a[0] % 2, 0, 0 }); rep(i, n) { if (get<0>(rle.back()) == a[i] % 2) { get<1>(rle.back())++; get<2>(rle.back()) += a[i]; } else { rle.push_back({ a[i] % 2, 1, a[i] }); } } for (auto [parity, cnt, sum] : rle) { if (parity == 1 && cnt >= m) cout << sum << endl; } return 0; }