提出 #72352378


ソースコード 拡げる

#include <iostream>
#include <vector>
#define fastio cin.tie(0)->sync_with_stdio(0)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define compress(v) sort(all(v)), v.erase(unique(all(v)), v.end())
#define sz(x) (int)(x).size()
using namespace std;

typedef long long ll;
int main() {
    fastio; int T; cin >> T;
    for (int tc = 0; tc < T; tc++) {
        int N, W; cin >> N >> W;
        vector<int> v(N);
        for (auto& i : v) cin >> i;
        vector<ll> sum(2*W);
        for (int i = 0; i < N; i++) {
            sum[i % (2*W)] += v[i];
        }
        for (int i = 0; i < W; i++) {
            sum.push_back(sum[i]);
        }
        ll t = 0;
        for (int i = 0; i < W; i++) {
            t += sum[i];
        }
        ll ans = t;
        for (int i = W; i < 3*W; i++) {
            t -= sum[i-W]; t += sum[i];
            ans = min(ans, t);
        }
        cout << ans << "\n";
    }
    return 0;
}

提出情報

提出日時
問題 C - Striped Horse
ユーザ Lov34ever
言語 C++23 (GCC 15.2.0)
得点 300
コード長 989 Byte
結果 AC
実行時間 12 ms
メモリ 10380 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 300 / 300
結果
AC × 1
AC × 27
セット名 テストケース
Sample sample_01.txt
All random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt, random_25.txt, random_26.txt, sample_01.txt
ケース名 結果 実行時間 メモリ
random_01.txt AC 7 ms 3636 KiB
random_02.txt AC 8 ms 3656 KiB
random_03.txt AC 8 ms 3552 KiB
random_04.txt AC 8 ms 3592 KiB
random_05.txt AC 9 ms 3788 KiB
random_06.txt AC 10 ms 5104 KiB
random_07.txt AC 9 ms 3624 KiB
random_08.txt AC 10 ms 5484 KiB
random_09.txt AC 9 ms 3624 KiB
random_10.txt AC 9 ms 4692 KiB
random_11.txt AC 9 ms 3712 KiB
random_12.txt AC 10 ms 7052 KiB
random_13.txt AC 9 ms 3724 KiB
random_14.txt AC 10 ms 5344 KiB
random_15.txt AC 9 ms 3724 KiB
random_16.txt AC 10 ms 5180 KiB
random_17.txt AC 9 ms 3724 KiB
random_18.txt AC 9 ms 4136 KiB
random_19.txt AC 9 ms 3732 KiB
random_20.txt AC 8 ms 4032 KiB
random_21.txt AC 2 ms 3624 KiB
random_22.txt AC 5 ms 7952 KiB
random_23.txt AC 12 ms 10380 KiB
random_24.txt AC 10 ms 7248 KiB
random_25.txt AC 9 ms 4720 KiB
random_26.txt AC 11 ms 7280 KiB
sample_01.txt AC 1 ms 3608 KiB