Submission #72364647


Source Code Expand

/*
Contest Name : AtCoder Beginner Contest 440
Problem : C Striped Horse
Date : 2026-01-10
Time taken : 
*/
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<vector>
using namespace std;
using ll=long long;
int main(){
    ios::sync_with_stdio(0);cin.tie(0);
    int T;cin>>T;
    while(T--){
        int n,W;cin>>n>>W;
        vector<ll>c(n);
        for(auto&x:c)cin>>x;
        int m=2*W;
        vector<ll>d(m+2,0);
        for(int i=0;i<n;++i){
            int r=(i+1)%m;
            int L=(r-W+1+m)%m,R=r;
            if(L<=R)d[L]+=c[i],d[R+1]-=c[i];
            else d[L]+=c[i],d[m]-=c[i],d[0]+=c[i],d[R+1]-=c[i];
        }
        ll res=1e18,cur=0;
        for(int x=0;x<m;++x)cur+=d[x],res=min(res,cur);
        cout<<res<<'\n';
    }
    return 0;
}

Submission Info

Submission Time
Task C - Striped Horse
User Queryme
Language C++23 (GCC 15.2.0)
Score 300
Code Size 845 Byte
Status AC
Exec Time 11 ms
Memory 8020 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 1
AC × 27
Set Name Test Cases
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
Case Name Status Exec Time Memory
random_01.txt AC 7 ms 3648 KiB
random_02.txt AC 7 ms 3604 KiB
random_03.txt AC 8 ms 3588 KiB
random_04.txt AC 8 ms 3600 KiB
random_05.txt AC 9 ms 3720 KiB
random_06.txt AC 10 ms 4816 KiB
random_07.txt AC 9 ms 3720 KiB
random_08.txt AC 10 ms 5044 KiB
random_09.txt AC 9 ms 3720 KiB
random_10.txt AC 9 ms 5260 KiB
random_11.txt AC 9 ms 3588 KiB
random_12.txt AC 10 ms 6356 KiB
random_13.txt AC 9 ms 3784 KiB
random_14.txt AC 10 ms 4992 KiB
random_15.txt AC 9 ms 3736 KiB
random_16.txt AC 10 ms 4876 KiB
random_17.txt AC 9 ms 3676 KiB
random_18.txt AC 9 ms 4820 KiB
random_19.txt AC 9 ms 3620 KiB
random_20.txt AC 9 ms 4284 KiB
random_21.txt AC 2 ms 3732 KiB
random_22.txt AC 3 ms 5696 KiB
random_23.txt AC 11 ms 8020 KiB
random_24.txt AC 10 ms 6556 KiB
random_25.txt AC 9 ms 5152 KiB
random_26.txt AC 10 ms 6432 KiB
sample_01.txt AC 1 ms 3604 KiB