为什么会有WA的点?按照题意模拟的
查看原帖
为什么会有WA的点?按照题意模拟的
250699
mot1ve楼主2020/9/22 21:40

@metaphysis 呼叫大佬

#include<bits/stdc++.h>
#define int long long
using namespace std;
int idx,n,h,k,now,cnt;//sum表示已经塞入的长度 
int a[100010];
signed main()
{
	cin>>n>>h>>k;
	memset(a,0x3f,sizeof(a));
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
	}
	while(1)
	{
		cnt++;//cnt读秒 
		while(h-now>=a[idx+1])//先处理能不能塞 
		{
			idx++;
			now+=a[idx];//塞入 
		}
		now-=k;
		if(idx==n&&now<=0)
		break;
	}
	cout<<cnt;
	return 0;
}
2020/9/22 21:40
加载中...