codeforces-2
B.chocolates
#include<iostream>
#include<algorithm>
#include<string.h>
long long b[200010];
long long x=1000000000+1;
using namespace std;
int main()
{
int n;
cin>>n;
for(int i=1;i<=n;i++)
scanf("%d",&b[i]);
long long ans=0;
for(int i=n;i;i--)
{
x=min(b[i],x-1);
if(x>0) ans+=x;
}
cout<<ans<<endl;
return 0;
}
每次的题目要求一定要看,看它的一个数据范围,一定要重视!!
第二这里面用了贪心算法
codeforces-2的更多相关文章
- python爬虫学习(5) —— 扒一下codeforces题面
上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...
- 【Codeforces 738D】Sea Battle(贪心)
http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...
- 【Codeforces 738C】Road to Cinema
http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...
- 【Codeforces 738A】Interview with Oleg
http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interv ...
- CodeForces - 662A Gambling Nim
http://codeforces.com/problemset/problem/662/A 题目大意: 给定n(n <= 500000)张卡片,每张卡片的两个面都写有数字,每个面都有0.5的概 ...
- CodeForces - 274B Zero Tree
http://codeforces.com/problemset/problem/274/B 题目大意: 给定你一颗树,每个点上有权值. 现在你每次取出这颗树的一颗子树(即点集和边集均是原图的子集的连 ...
- CodeForces - 261B Maxim and Restaurant
http://codeforces.com/problemset/problem/261/B 题目大意:给定n个数a1-an(n<=50,ai<=50),随机打乱后,记Si=a1+a2+a ...
- CodeForces - 696B Puzzles
http://codeforces.com/problemset/problem/696/B 题目大意: 这是一颗有n个点的树,你从根开始游走,每当你第一次到达一个点时,把这个点的权记为(你已经到过不 ...
- CodeForces - 148D Bag of mice
http://codeforces.com/problemset/problem/148/D 题目大意: 原来袋子里有w只白鼠和b只黑鼠 龙和王妃轮流从袋子里抓老鼠.谁先抓到白色老鼠谁就赢. 王妃每次 ...
- CodeForces - 453A Little Pony and Expected Maximum
http://codeforces.com/problemset/problem/453/A 题目大意: 给定一个m面的筛子,求掷n次后,得到的最大的点数的期望 题解 设f[i]表示掷出 <= ...
随机推荐
- Stars HDU - 1541
HDU - 1541 思路:二维偏序,一维排序,一维树状数组查询即可. #include<bits/stdc++.h> using namespace std; #define maxn ...
- Vim使用心得
马上就要联赛啦. 学习一下vim 这是一个vim文档 http://vimcdoc.sourceforge.net/doc/ 这是一个优秀的vimrc配置 http://www.cnblogs.com ...
- Django——图书管理系统
基于Django的图书管理系统 1.主体功能 1.列出图书列表.出版社列表.作者列表 2.点击作者,会列出其出版的图书列表 3.点击出版社,会列出旗下图书列表 4.可以创建.修改.删除 图书.作者.出 ...
- MySQL中count函数使用方法详解
count函数是用来统计表中或数组中记录的一个函数,下面我来介绍在MySQL中count函数用法与性能比较吧. count(*) 它返回检索行的数目, 不论其是否包含 NULL值. SELECT ...
- JavaScript 常见错误
1. 严格缩进 JavaScript 会自动添加句末的分号,导致一些难以察觉的错误 return { key: value }; // 相当于 return; { key: value }; 2. 括 ...
- apt-get安装mysql
1,检查是否已安装. 2,安装: apt-get install mysql-client-core-5.5 apt-get install mysql-server mysql-client 安装过 ...
- pytorch入门与实践-3 Tensor详解
1--如第二章所讲,Tensor的本质是矩阵或数据 2--对Tensor的操作分类 |----API分类 |------torch中定义的: t.f(a,b) |------tensor的成员函数: ...
- symfony采坑
2018年7月31日21:43:17 安装 首先安装composer 注意 windows下注意 [curl] curl.cainfo =E:\phpStudy\PHPTutorial\php\p ...
- js 中数组的遍历
var x = ['a','b','c'] x.forEach(function(val,k){ console.log(val + '--' +k); }) a--0 b-- 1 c-- 2 var ...
- Codeforces 785D - Anton and School - 2 - [范德蒙德恒等式][快速幂+逆元]
题目链接:https://codeforces.com/problemset/problem/785/D 题解: 首先很好想的,如果我们预处理出每个 "(" 的左边还有 $x$ 个 ...