Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
33611 | LYLAKIOI | 【S】T3 | C++ | 通过 | 100 | 1 MS | 992 KB | 885 | 2024-10-16 12:56:18 |
#include<bits/stdc++.h> #define up(i,l,r) for(int i=(l);i<=(r);++i) #define down(i,l,r) for(int i=(l);i>=(r);--i) #define pi pair<int,int> #define p1 first #define p2 second #define p_b push_back #define m_p make_pair typedef long long ll; typedef unsigned long long ull; using namespace std; const int maxn=1e5+10; inline ll read(){ ll x=0;short t=1;char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')t=-1;ch=getchar();} while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar(); return x*t; } int n,d,ct[maxn],a[maxn]; void slv(){ n=read(),d=read(); up(i,1,n)a[i]=read();int cnt=0; up(i,1,n)if(a[i])cnt++,ct[i%d]++; int mx=1e9; up(i,0,d-1)mx=min(mx,cnt-ct[i]); cout<<mx; }int main(){ //freopen("c.in","r",stdin); //freopen("c.out","w",stdout); slv(); fclose(stdin); fclose(stdout); return 0; }