Submission #72354606


Source Code Expand

#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=1e6+10;
int cnt[N];
void solve(){
	int n,w;cin>>n>>w;
	for(int i=0;i<2*w;i++) cnt[i]=0;
	for(int i=1;i<=n;i++){
		int x;cin>>x;int r=i%(2*w);
		if(r<w) cnt[0]+=x,cnt[w-r]-=x,cnt[2*w-r]+=x;
		else cnt[2*w-r]+=x,cnt[3*w-r]-=x;
	}
	for(int i=1;i<2*w;i++) cnt[i]+=cnt[i-1];
	int ans=1e18;
	for(int i=0;i<2*w;i++) ans=min(ans,cnt[i]);
	cout<<ans<<"\n";
}
signed main(){
	ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(0);
	int T=1;cin>>T;
	while(T--) solve();
	return 0;
}

Submission Info

Submission Time
Task C - Striped Horse
User dogger_of_V
Language C++23 (Clang 21.1.0)
Score 300
Code Size 575 Byte
Status AC
Exec Time 91 ms
Memory 6156 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 47 ms 2816 KiB
random_02.txt AC 40 ms 2892 KiB
random_03.txt AC 43 ms 2844 KiB
random_04.txt AC 42 ms 2848 KiB
random_05.txt AC 86 ms 2992 KiB
random_06.txt AC 84 ms 3608 KiB
random_07.txt AC 87 ms 2840 KiB
random_08.txt AC 85 ms 3832 KiB
random_09.txt AC 85 ms 2804 KiB
random_10.txt AC 84 ms 3340 KiB
random_11.txt AC 84 ms 2840 KiB
random_12.txt AC 85 ms 4428 KiB
random_13.txt AC 85 ms 2992 KiB
random_14.txt AC 84 ms 3724 KiB
random_15.txt AC 85 ms 2844 KiB
random_16.txt AC 84 ms 3584 KiB
random_17.txt AC 85 ms 2936 KiB
random_18.txt AC 85 ms 2956 KiB
random_19.txt AC 85 ms 2968 KiB
random_20.txt AC 85 ms 2840 KiB
random_21.txt AC 4 ms 2956 KiB
random_22.txt AC 3 ms 5068 KiB
random_23.txt AC 86 ms 6156 KiB
random_24.txt AC 85 ms 4328 KiB
random_25.txt AC 84 ms 3232 KiB
random_26.txt AC 91 ms 4528 KiB
sample_01.txt AC 1 ms 2816 KiB