Codeforces 839A Arya and Bran (模拟)

来源:互联网 发布:openbugs软件 编辑:程序博客网 时间:2024/05/16 16:02

题目链接

CF 839A

题目大意

分析

代码

#include <bits/stdc++.h>using namespace std;const double pi=4*atan(1.0);int main(){    int a[110],n,k,i;    while (scanf("%d%d",&n,&k)!=EOF)    {        for (i=1;i<=n;i++)            scanf("%d",&a[i]);        for (i=1;i<=n;i++)        {            if (a[i]<=8)                k-=a[i];            else            {                k-=8;                a[i+1]+=(a[i]-8);            }            if (k<=0)            {                cout<<i<<endl;                break;            }        }        if (k>0) cout<<-1<<endl;    }    return 0;}