唯一要注意的是前一天剩下的可以存起来以后发

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<set>
#include<stack>
#include<queue>
#include<ctype.h>
#include<vector>
#include<algorithm>
// cout << "  ===  " << endl;using namespace std;
typedef long long ll;
const int maxn = 1000 + 7, INF = 0x3f3f3f3f, mod = 1e9+7;
int n, m;
int a[maxn];int main() {scanf("%d%d", &n, &m);int sum = 0;for(int i = 1; i <= n; ++i)scanf("%d", &a[i]);for(int i = 1; i <= n; ++i) {if(a[i] >= 8) {m -= 8;sum += a[i] - 8;}else {int t = 8 - a[i];m -= a[i];m -= min(t, sum);sum = max(0, sum - t);}//cout << m << " ++ ++ " << endl;if(m <= 0) {cout << i << endl;return 0;}}cout << -1 << endl;return 0;
}

CodeForces 839A Arya and Bran相关推荐

  1. codeforces 839A Arya and Bran

    点击打开链接 A. Arya and Bran time limit per test 1 second memory limit per test 256 megabytes input stand ...

  2. Codeforces #839A: Arya and Bran 题解

    这题直接模拟就好了 将这天能得到的糖果加进计数器,如果当天多于8个就给八个,否则给光 n天后,看能否给出不少于k个的糖果 #include <cstdio> #include <io ...

  3. CF 839A - Arya and Bran(水)

    Discription 给定n天,每天有a[i]个蛋糕.小明一共需要k个蛋糕,每天给小明的蛋糕数量<=8,如果今天给了小明8个蛋糕后有剩余,可以将剩余的蛋糕积攒到明天,以此类推,问小明最少几天能 ...

  4. Codeforces Round #428 (Div. 2):A. Arya and Bran

    题目: Bran and his older sister Arya are from the same house. Bran like candies so much, so Arya is go ...

  5. Arya and Bran Game of the Rows Multiple Clocks

    题目一:Arya and Bran 错解: #include<cstdio> int main() {int n,k,candy;int left = 0,day = 0,toGive = ...

  6. codeforces 839A

    水题  题意 分糖果  每次最多8个  多出来的可以遗留到下一天 注意下一天少于8个要清0: 代码: #include<bits/stdc++.h> using namespace std ...

  7. Codeforces 题目合集+分类+代码 【Updating...】【361 in total】

    961A - Tetris                                                模拟                                      ...

  8. python运行mcmc为何老出错_python中mcmc方法的实现

    MCMC方法在贝叶斯统计中运用很多,MIT发布的EMCEE是实现的比较好的.介绍页面在下面.源代码中examples里的代码可以帮助理解各种功能,特别是line.py 列出了最小二乘法,最大似然法和M ...

  9. Codeforces--839A--Arya and Bran

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

最新文章

  1. Habitica 4.85.5 发布,习惯游戏养成应用
  2. Opengl-基本概念-纹理(单纯的颜色太单调弄张图显示不是更好)
  3. readonly时禁用删除键,readonly按删除键后页面后退解决方案
  4. LINUX技术讨论区
  5. php require 500,thinkphp5出现500错误怎么办
  6. 国自然和毕业论文的流程图用这个格式导入Word可无限放大
  7. 《Ext JS权威指南》——1.2节JSON概述
  8. Oracle11g 统计信息——统计信息自动收集任务
  9. 关于浙大考研878历年试卷的说明
  10. Akka 2 Actor 源码
  11. Symbian 之浏览器
  12. 基于SSM实现个性化健康饮食推荐系统
  13. 用python画钢铁侠_秒变钢铁侠,这个暑假,用 Python 让自己成为超级英雄!
  14. 视频流媒体直播平台运行报Only one usage错误原因排查分析
  15. 5分钟入门Cinemachine智能相机系统
  16. PowerBuilder 部署iis报错:IIS is not acessblee Please check the server address and port number.
  17. 微信分享,缩略图显示不出来
  18. 软考下午题第1题——数据流,题目分析与案例解析:
  19. python和java都是用c文件吗_python是用C实现的,Java是用C++实现的,那为什么不直接用C或C++呢?...
  20. 解决vscode c++ 无法跳转代码(区别于大部分网上的解决方案)

热门文章

  1. 连续自然数平立方求和推导
  2. 对话出门问问李志飞:GPT-3 是「暴力美学」的一次胜利
  3. 怎么用feign远程调用别人的接口_Feign - HTTP接口调用- 单独使用 - 实战
  4. 测量CAD图纸中2点之间的距离,有哪几种好用方法?
  5. HAWKER叉车蓄电池 FLEX LI3 现已通过 UL 2580 认证 霍克叉车电瓶
  6. linux下修改hosts文件没有权限
  7. 神仙爱情!年轻富翁捐5亿科研经费,让女友不用申请项目,专心搞科研!
  8. 西北大学电影专硕考研考情与难度、参考书及上岸前辈备考经验
  9. Unity中根据矩阵判断一个点在自身的哪一侧
  10. 新能源汽车充电桩检测标准介绍