Submission #72351048


Source Code Expand

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vl=vector<long long>;
using vvl=vector<vector<long long>>;
using vvvl=vector<vector<vector<long long>>>;
using pl=pair<long long,long long>;
using vpl=vector<pair<long long,long long>>;
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(long long i=(long long)(a);i<(long long)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#include <atcoder/all>
using namespace atcoder;

long long modpow(long long a, long long n, long long mo){long long res=1;while(n>0){if(n&1){res=res*a%mo;}a=a*a%mo;n>>=1;}return res;}
long long Pow(long long a, long long n){long long res=1;while(n>0){if(n&1){res=res*a;}a=a*a;n>>=1;}return res;}

const ll MOD=998244353;
const ll INF=(1ll<<60);
int main(){
  ll T;
  cin>>T;
  rep(jfodat,T){
    ll N,W;
    cin>>N>>W;
    vl C(N);
    rep(i,N){
      cin>>C[i];
    }
    vl D(2*W*2,0);
    rep(i,N){
      D[i%(2*W)]+=C[i];
    }
    rep(i,2*W) D[i+2*W]=D[i];
    ll ans=0;
    ll now=0;
    rep(i,W) now+=D[i];
    ans=now;
    rep(i,2*W-1){
      now-=D[i];
      now+=D[i+W];
      ans=min(ans,now);
    }
    cout<<ans<<endl;
  }
}

Submission Info

Submission Time
Task C - Striped Horse
User number_cat
Language C++23 (GCC 15.2.0)
Score 300
Code Size 1397 Byte
Status AC
Exec Time 61 ms
Memory 11092 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 31 ms 3596 KiB
random_02.txt AC 31 ms 3448 KiB
random_03.txt AC 33 ms 3612 KiB
random_04.txt AC 33 ms 3608 KiB
random_05.txt AC 55 ms 3660 KiB
random_06.txt AC 55 ms 5588 KiB
random_07.txt AC 54 ms 3712 KiB
random_08.txt AC 56 ms 5968 KiB
random_09.txt AC 53 ms 3744 KiB
random_10.txt AC 55 ms 5428 KiB
random_11.txt AC 55 ms 3784 KiB
random_12.txt AC 56 ms 7976 KiB
random_13.txt AC 55 ms 3740 KiB
random_14.txt AC 56 ms 5808 KiB
random_15.txt AC 55 ms 3744 KiB
random_16.txt AC 55 ms 5964 KiB
random_17.txt AC 54 ms 3616 KiB
random_18.txt AC 54 ms 4820 KiB
random_19.txt AC 54 ms 3544 KiB
random_20.txt AC 55 ms 4264 KiB
random_21.txt AC 3 ms 3712 KiB
random_22.txt AC 5 ms 7992 KiB
random_23.txt AC 58 ms 11092 KiB
random_24.txt AC 56 ms 8144 KiB
random_25.txt AC 55 ms 5584 KiB
random_26.txt AC 61 ms 8052 KiB
sample_01.txt AC 1 ms 3432 KiB