A. Arya and Bran

time limit per test:1 second
memory limit per test:256 megabytes
input:standard input
output:standard output

Bran and his older sister Arya are from the same house. Bran like candies so much, so Arya is going to give him some Candies.

At first, Arya and Bran have 0 Candies. There are n days, at the i-th day, Arya finds ai candies in a box, that is given by the Many-Faced God. Every day she can give Bran at most 8 of her candies. If she don't give him the candies at the same day, they are saved for her and she can give them to him later.

Your task is to find the minimum number of days Arya needs to give Bran k candies before the end of the n-th day. Formally, you need to output the minimum day index to the end of which k candies will be given out (the days are indexed from 1 to n).

Print -1 if she can't give him k candies during n given days.

Input

The first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 10000).

The second line contains n integers a1, a2, a3, ..., an (1 ≤ ai ≤ 100).

Output

If it is impossible for Arya to give Bran k candies within n days, print -1.

Otherwise print a single integer — the minimum number of days Arya needs to give Bran k candies before the end of the n-th day.

Examples
Input
2 3
1 2
Output
2
Input
3 17
10 10 10
Output
3
Input
1 9
10
Output
-1
Note

In the first sample, Arya can give Bran 3 candies in 2 days.

In the second sample, Arya can give Bran 17 candies in 3 days, because she can give him at most 8 candies per day.

In the third sample, Arya can't give Bran 9 candies, because she can give him at most 8 candies per day and she must give him the candies within 1 day.

题目链接:http://codeforces.com/contest/839/problem/A

分析:题意大概是第n天结束之前需要给予Bran k糖果的最少天数,暴力即可,不过这题目题意确实有点迷就是了!

下面给出AC代码:

 #include <bits/stdc++.h>
using namespace std;
int main()
{
int n,m;
cin>>n>>m;
int ans=;
for(int i=;i<=n;i++)
{
int x;
cin>>x;
ans+=x;
m-=min(ans,);
ans-=min(ans,);
if(m<=)
return !printf("%d\n",i);
}
return !printf("-1\n");
}

Codeforces 839A Arya and Bran【暴力】的更多相关文章

  1. Codeforces 839A Arya and Bran

    Bran and his older sister Arya are from the same house. Bran like candies so much, so Arya is going ...

  2. codeforce 839A Arya and Bran(水题)

    Bran and his older sister Arya are from the same house. Bran like candies so much, so Arya is going ...

  3. 839A Arya and Bran

    A. Arya and Bran time limit per test 1 second memory limit per test 256 megabytes input standard inp ...

  4. Codeforces Round #428 A. Arya and Bran【模拟】

    A. Arya and Bran time limit per test 1 second memory limit per test 256 megabytes input standard inp ...

  5. A. Arya and Bran

    A. Arya and Bran time limit per test 1 second memory limit per test 256 megabytes input standard inp ...

  6. 【Codeforces Round #428 (Div. 2) A】Arya and Bran

    [Link]: [Description] [Solution] 傻逼题 [NumberOf WA] [Reviw] [Code] #include <bits/stdc++.h> usi ...

  7. Codeforces Gym 100015H Hidden Code 暴力

    Hidden Code 题目连接: http://codeforces.com/gym/100015/attachments Description It's time to put your hac ...

  8. Codeforces gym 100685 A. Ariel 暴力

    A. ArielTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100685/problem/A Desc ...

  9. Codeforces Gym 100637G G. #TheDress 暴力

    G. #TheDress Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100637/problem/G ...

随机推荐

  1. 【java】io流之字节输出流:java.io.OutputStream类及子类java.io.FileOutputStream

    package 文件操作; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; impo ...

  2. iOS Label 自适应高度

    推荐第二个 测试一,只改变numberOfLines属性,label的高度不会自适应(会有text中的一部分内容称为......) NSString *str = @"jgreijgirje ...

  3. iOS: FFmpeg编译和使用 学习

    ffmpeg是一个多平台多媒体处理工具,处理视频和音频的功能非常强大.目前在网上搜到的iOS上使用FFMPEG的资料都比较陈旧,而FFMPEG更新迭代比较快: 且网上的讲解不够详细,对于初次接触FFM ...

  4. 每周.NET前沿技术文章摘要(2017-05-10)

    汇总国内外.NET社区相关文章,覆盖.NET ,ASP.NET和Docker容器三个方面的内容: .NET Debugging .NET core with SOS everywhere 链接:htt ...

  5. PHP-无限级分类(迭代法创建)

    $area = array( array('id'=>1,'name'=>'安徽','parent'=>0), array('id'=>2,'name'=>'海淀','p ...

  6. fdisk 命令详解

    fdisk  作用: 查看磁盘实体使用情况,也可对硬盘分区. 选项:  -b 分区大小 -l  列出指定的外围设备的分区表状况 -s 分区编号, 将指定的分区大小输出到标准输出上, 单位为区块 -u ...

  7. (一)初识mybatis

    Mybatis 是现在很多公司都选择使用的一个ORM(Object Relational Mapping)框架,所以是值得了解和学习一番的. MyBatis 是支持定制化 SQL.存储过程以及高级映射 ...

  8. Discuz uc.key泄露导致代码注入漏洞

    漏洞描述:在Discuz中,uc_key是UC客户端与服务端通信的通信密钥,discuz中的/api/uc.php存在代码写入漏洞,导致黑客可写入恶意代码获取uckey,最终进入网站后台,造成数据泄漏 ...

  9. 使用ListView控件展示数据

    属性名称    说明items   指定显示那种视图View   指定显示那种视图largelmagelist  大图标图像的imagelist控件SmallLmagelist  小图标图像的imag ...

  10. Django__RBAC

    RBAC : 基于角色的权限访问控制(Role-Based Access Control) RBAC 模型作为目前最为广泛接受的权限模型 角色访问控制(RBAC)引入了Role的概念,目的是为了隔离U ...