社区讨论

90求

P1614爱与愁的心痛参与者 2已保存回复 2

讨论操作

快速查看讨论及其快照的属性,并进行相关操作。

当前回复
2 条
当前快照
1 份
快照标识符
@mhjakfw2
此快照首次捕获于
2025/11/03 23:25
4 个月前
此快照最后确认于
2025/11/03 23:25
4 个月前
查看原帖
CPP
#include<bits/stdc++.h>
using namespace std;
int ans,n,m,a[30005],h[30005];
int main() {
	cin>>n>>m;
	for(int i=1; i<=n; i++)cin>>a[i];
	for(int i=1; i<=n-m; i++) {
		for(int j=i; j<i+m; j++) {
			h[i]=h[i]+a[j];
		}
	}
	sort(h,h+n-m+1);
	cout<<h[1];
	return 0;
}

回复

2 条回复,欢迎继续交流。

正在加载回复...