版权声明:欢迎大佬指正! https://blog.csdn.net/sinat_36215255/article/details/82118727
题目https://vjudge.net/problem/Aizu-1380
想的太复杂了,真的,写都不好写,写完了也写wa了;
把我心态都搞崩了。
思路:
如果画一个区间图,仔细分析的话,就会发现,每次的可以进行的项目数,与之前出现过的最大值有关,等待时间加上当前操作的执行时间,其实是最大时间,所以以mxx,为划分区间,
注意:当等待的时候,项目数应该加1
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <string>
#include <map>
#include <cstdio>
#include <cstring>
#include <vector>
#define ll long long
using namespace std;
const int maxn = 1e5+5;
const int inf = 0x3f3f3f3f;
ll a[maxn];
ll bet[maxn];
ll ans[maxn];
int main()
{
ll n,endt;
scanf("%lld%lld",&n,&endt);
for(int i=1; i<=n; i++)
{
scanf("%lld",&a[i]);
}
bet[0] = 0;
bet[1] = 0;
for(int i=2; i<=n; i++)
{
bet[i] = bet[i-1] + a[i-1];
}
ll mxx = a[1];
ans[1] = endt/a[1] + 1;
for(int i=2; i<=n; i++)
{
//cout<<bet[i]<<endl;
if(endt<=bet[i])
{
ans[i] = 1;
continue;
}
if(a[i]>=mxx)
ans[i] = (double)(endt - bet[i])/(double)a[i] + 1;
else
{
ans[i] = (double)(endt - bet[i])/(double)mxx + 1;
ll d = (endt - bet[i])%mxx;
if(d>=a[i])
ans[i]++;
}
mxx = max(mxx,a[i]);
}
for(int i=1; i<=n; i++)
cout<<ans[i]<<endl;
return 0;
}