Berland Fair CodeForces - 1073D

http://codeforces.com/contest/1073/problem/D

一开始线段树和双端链表各种维护 越写越不对劲。。

其实直接暴力就好 先看逛上一圈能加就加 能买多少 再看这种情况下能逛几圈 最后取一下模就是log的复杂度了

 

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=2e5+10;

ll ary[maxn];
ll tot;
int n;

int main()
{
    ll ans,sum,cnt;
    int i;
    scanf("%d%lld",&n,&tot);
    for(i=1;i<=n;i++) scanf("%lld",&ary[i]);
    ans=0;
    while(1){
        sum=0,cnt=0;
        for(i=1;i<=n;i++) if(sum+ary[i]<=tot) sum+=ary[i],cnt++;
        if(cnt==0) break;
        ans+=(tot/sum)*cnt;
        tot%=sum;
    }
    printf("%lld\n",ans);
    return 0;
}

yi'kai

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值