Submission #72372435


Source Code Expand

#include<bits/stdc++.h>
#define int long long
#define MSOD
//#define READ_IN_FILE
#define endl '\n'
#define FAST ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
const int N = 4e5 + 10, P = 998244353, MOD = 1e9 + 7, inf = 0x3f3f3f3f;
bool cmpbig(int i,int j)
{
	return i>j;
}
double mylog(int x,int y)
{
	return log(x)/log(y);
}
long long qpow(long long a,long long b,long long mod=LLONG_MAX)
{
	long long num=1;
	while(b)
	{
		if(b&1)num=num*a%mod;
		a=a*a%mod;
		b>>=1;
	}
	return num;
}
int n, w, s[2 * N], num[2 * N],ans;
void solve()
{
	cin >> n >> w;
	int mod = 2 * w, tn = 4 * w;
	for (int i = 0; i < mod; i++)num[i] = 0;
	for (int i = 1; i <= n; i++)
	{
		int tmp;
		cin >> tmp;
		num[i % mod] += tmp;
	}
	for (int i = 0; i < tn; i++)s[i + 1] = s[i] + num[i % mod];
  ans = 1e18;
	for (int i = 0; i + w <= tn; i++) {
		int cur = s[i + w] - s[i];
		ans=min(ans,cur);
	}
	cout << ans << endl;
}
signed main()
{
	FAST
#ifdef READ_IN_FILE
	freopen(".in",  "r", stdin);
	freopen(".out",  "w", stdout);
#endif
	int _T_ = 1;
#ifdef MSOD
	cin >> _T_;
#endif
	while (_T_--) solve();
	return 0;
}

Submission Info

Submission Time
Task C - Striped Horse
User Little_Cck
Language C++23 (GCC 15.2.0)
Score 300
Code Size 1178 Byte
Status AC
Exec Time 14 ms
Memory 13028 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 3644 KiB
random_02.txt AC 7 ms 3684 KiB
random_03.txt AC 8 ms 3700 KiB
random_04.txt AC 8 ms 3692 KiB
random_05.txt AC 9 ms 3696 KiB
random_06.txt AC 11 ms 5864 KiB
random_07.txt AC 9 ms 3736 KiB
random_08.txt AC 11 ms 6252 KiB
random_09.txt AC 10 ms 3596 KiB
random_10.txt AC 9 ms 4492 KiB
random_11.txt AC 9 ms 3652 KiB
random_12.txt AC 11 ms 8100 KiB
random_13.txt AC 9 ms 3652 KiB
random_14.txt AC 11 ms 5988 KiB
random_15.txt AC 10 ms 3612 KiB
random_16.txt AC 10 ms 5732 KiB
random_17.txt AC 9 ms 3736 KiB
random_18.txt AC 8 ms 3648 KiB
random_19.txt AC 8 ms 3776 KiB
random_20.txt AC 9 ms 3524 KiB
random_21.txt AC 4 ms 3776 KiB
random_22.txt AC 6 ms 10560 KiB
random_23.txt AC 14 ms 13028 KiB
random_24.txt AC 11 ms 8300 KiB
random_25.txt AC 9 ms 4616 KiB
random_26.txt AC 11 ms 8256 KiB
sample_01.txt AC 1 ms 3648 KiB