CodeForces 839A Arya and Bran
唯一要注意的是前一天剩下的可以存起来以后发
#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相关推荐
- codeforces 839A Arya and Bran
点击打开链接 A. Arya and Bran time limit per test 1 second memory limit per test 256 megabytes input stand ...
- Codeforces #839A: Arya and Bran 题解
这题直接模拟就好了 将这天能得到的糖果加进计数器,如果当天多于8个就给八个,否则给光 n天后,看能否给出不少于k个的糖果 #include <cstdio> #include <io ...
- CF 839A - Arya and Bran(水)
Discription 给定n天,每天有a[i]个蛋糕.小明一共需要k个蛋糕,每天给小明的蛋糕数量<=8,如果今天给了小明8个蛋糕后有剩余,可以将剩余的蛋糕积攒到明天,以此类推,问小明最少几天能 ...
- 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 ...
- 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 = ...
- codeforces 839A
水题 题意 分糖果 每次最多8个 多出来的可以遗留到下一天 注意下一天少于8个要清0: 代码: #include<bits/stdc++.h> using namespace std ...
- Codeforces 题目合集+分类+代码 【Updating...】【361 in total】
961A - Tetris 模拟 ...
- python运行mcmc为何老出错_python中mcmc方法的实现
MCMC方法在贝叶斯统计中运用很多,MIT发布的EMCEE是实现的比较好的.介绍页面在下面.源代码中examples里的代码可以帮助理解各种功能,特别是line.py 列出了最小二乘法,最大似然法和M ...
- 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 ...
最新文章
- Habitica 4.85.5 发布,习惯游戏养成应用
- Opengl-基本概念-纹理(单纯的颜色太单调弄张图显示不是更好)
- readonly时禁用删除键,readonly按删除键后页面后退解决方案
- LINUX技术讨论区
- php require 500,thinkphp5出现500错误怎么办
- 国自然和毕业论文的流程图用这个格式导入Word可无限放大
- 《Ext JS权威指南》——1.2节JSON概述
- Oracle11g 统计信息——统计信息自动收集任务
- 关于浙大考研878历年试卷的说明
- Akka 2 Actor 源码
- Symbian 之浏览器
- 基于SSM实现个性化健康饮食推荐系统
- 用python画钢铁侠_秒变钢铁侠,这个暑假,用 Python 让自己成为超级英雄!
- 视频流媒体直播平台运行报Only one usage错误原因排查分析
- 5分钟入门Cinemachine智能相机系统
- PowerBuilder 部署iis报错:IIS is not acessblee Please check the server address and port number.
- 微信分享,缩略图显示不出来
- 软考下午题第1题——数据流,题目分析与案例解析:
- python和java都是用c文件吗_python是用C实现的,Java是用C++实现的,那为什么不直接用C或C++呢?...
- 解决vscode c++ 无法跳转代码(区别于大部分网上的解决方案)