Submission #72353759


Source Code Expand

#include<bits/stdc++.h>
using namespace std;
#define int long long 
const int N=1e6+6;
int T,n,w;
int c[N],sum[N];
vector<int> v[N];
int tmp[N];
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	cin>>T;
	while(T--){
		cin>>n>>w;
		for(int i=1;i<=n;i++)cin>>c[i];
		int qwq=2*w;
		for(int i=0;i<qwq;i++){
			v[i].clear();
			sum[i]=0;
		}
		for(int i=1;i<=n;i++){
			int r=(i-1)%qwq;
			v[r].push_back(c[i]);
		}
		for(int i=0;i<qwq;i++){
			for(auto item:v[i])sum[i]+=item;
		}
		for(int i=0;i<qwq;i++){
			tmp[i]=sum[i];
			tmp[i+qwq]=sum[i];
		}
		int cur=0;
		for(int i=0;i<w;i++)cur+=tmp[i];
		int ans=cur;
		for(int i=w;i<qwq+w;i++){
			cur+=tmp[i];
			cur-=tmp[i-w];
			if(ans>cur)ans=cur;
		}
		cout<<ans<<'\n';
	}
	return 0;
}

Submission Info

Submission Time
Task C - Striped Horse
User kac17
Language C++23 (GCC 15.2.0)
Score 300
Code Size 797 Byte
Status AC
Exec Time 25 ms
Memory 25488 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 10 ms 3720 KiB
random_02.txt AC 10 ms 3688 KiB
random_03.txt AC 10 ms 3744 KiB
random_04.txt AC 10 ms 3664 KiB
random_05.txt AC 12 ms 3756 KiB
random_06.txt AC 18 ms 11880 KiB
random_07.txt AC 12 ms 3836 KiB
random_08.txt AC 18 ms 13128 KiB
random_09.txt AC 12 ms 3700 KiB
random_10.txt AC 18 ms 10120 KiB
random_11.txt AC 13 ms 3680 KiB
random_12.txt AC 22 ms 19952 KiB
random_13.txt AC 13 ms 3592 KiB
random_14.txt AC 18 ms 12528 KiB
random_15.txt AC 12 ms 3768 KiB
random_16.txt AC 18 ms 11912 KiB
random_17.txt AC 12 ms 3700 KiB
random_18.txt AC 13 ms 7016 KiB
random_19.txt AC 12 ms 3664 KiB
random_20.txt AC 13 ms 5324 KiB
random_21.txt AC 6 ms 3592 KiB
random_22.txt AC 8 ms 10592 KiB
random_23.txt AC 25 ms 25488 KiB
random_24.txt AC 23 ms 20840 KiB
random_25.txt AC 18 ms 10224 KiB
random_26.txt AC 23 ms 20988 KiB
sample_01.txt AC 4 ms 3680 KiB