Increasing Sequence CodeForces - 11A
Increasing Sequence CodeForces - 11A
很简单的贪心。由于不能减少元素,只能增加,过程只能是从左到右一个个看过去,看到一个小于等于左边的数的数就把它加到比左边大,并记录加的次数。
错误记录:
但是很容易错...以前错了4次..过几个月来再做还是不能1A...
比如下面这个有很明显错误的程序
#include<cstdio>
int n,d,last,now,ans;
int main()
{
int i;
scanf("%d%d",&n,&d);
scanf("%d",&last);
for(i=;i<=n;i++)
{
scanf("%d",&now);
if(now<=last)
{
ans+=(last-now)/d+;
now+=d*ans;
}
last=now;
}
printf("%d",ans);
return ;
}
2333333
#include<cstdio>
int n,d,last,now,ans;
int main()
{
int i,tans;
scanf("%d%d",&n,&d);
scanf("%d",&last);
for(i=;i<=n;i++)
{
scanf("%d",&now);
if(now<=last)
{
tans=(last-now)/d+;
ans+=tans;
now+=d*tans;
}
last=now;
}
printf("%d",ans);
return ;
}
Increasing Sequence CodeForces - 11A的更多相关文章
- Codeforces Beta Round #11 A. Increasing Sequence 贪心
A. Increasing Sequence 题目连接: http://www.codeforces.com/contest/11/problem/A Description A sequence a ...
- Codeforces Round #279 (Div. 2) E. Restoring Increasing Sequence 二分
E. Restoring Increasing Sequence time limit per test 1 second memory limit per test 256 megabytes in ...
- Almost Regular Bracket Sequence CodeForces - 1095E (线段树,单点更新,区间查询维护括号序列)
Almost Regular Bracket Sequence CodeForces - 1095E You are given a bracket sequence ss consisting of ...
- cf 11A Increasing Sequence(水,)
题意: A sequence a0, a1, ..., at - 1 is called increasing if ai - 1 < ai for each i: 0 < i < ...
- Longest Increasing Sequence
public class Longest_Increasing_Subsequence { /** * O(N^2) * DP * 思路: * 示例:[1,0,2,4,10,5] * 找出以上数组的L ...
- AC日记——The Child and Sequence codeforces 250D
D - The Child and Sequence 思路: 因为有区间取模操作所以没法用标记下传: 我们发现,当一个数小于要取模的值时就可以放弃: 凭借这个来减少更新线段树的次数: 来,上代码: # ...
- C. Vasily the Bear and Sequence Codeforces 336C(枚举,思维)
C. Vasily the Bear and Sequence time limit per test 1 second memory limit per test 256 megabytes inp ...
- Prefix Product Sequence CodeForces - 487C (数论,构造)
大意: 构造一个[1,2,...n]的排列, 使得前缀积模n为[0,1,...,n-1]的排列 这种构造都好巧妙啊, 大概翻一下官方题解好了 对于所有>=6的合数$n$, 有$(n-1)! \e ...
- Almost Increasing Array CodeForces - 946G (dp)
大意: 定义几乎递增序列为删除不超过一个数后序列严格递增. 给定序列, 求最少改变多少个数能变为几乎递增序列. 跟hdu5256类似,
随机推荐
- Jekyll 搭建
Jekyll搭建个人主页 早上昨晚上弄hexo的时候就开始有问题,发现命令有错误!今天早上来就开始把另外建立了仓库,转Jekyll,并不顺利,做了一天了,基本的theme的本地和远端主页可以显示,但当 ...
- [React] Use the Fragment Short Syntax in Create React App 2.0
create-react-app version 2.0 added a lot of new features. One of the new features is upgrading to Ba ...
- Office PDF如何批量删除书签
网上下了本PDF,不知道哪个傻逼每一页都做了一个书签,我真的想做个书签,看看自己做到哪一页都被搞乱了.狗日的,还没有批量删除功能. 方法就是,你定位到任意一个书签,然后按住Delete键,然后就可 ...
- 百万级PHP网站Poppen.de的架构分享心得
在了解过世界最大的PHP站点,Facebook的后台技术后, 今天我们来了解一个百万级PHP站点的网站架构:Poppen.de.Poppen.de是德国的一个社交网站,相对Facebook.Flick ...
- 在matlab中生成m序列
实验环境为matlab2013b 1.首先编写一个mseq.m文件,内容为: function[mseq]=m_sequence(fbconnection) n=length(fbconnectio ...
- React笔记
React JS Tutorials for Beginners - 1 - Getting Started https://www.youtube.com/watch?v=-AbaV3nrw6E&a ...
- Eclipse项目遇到问题汇总
1:gc overhead limit exceeded 原因:这是由于项目中eclipse内存分配不足导致 修改:修改eclipse.ini文件 修改如下: ...
- redirect和rewrite
1 服务器端重定向 客户端想要访问的内容不在该服务器上,该服务器自己去另外的服务器请求到该内容,然后还是由该服务器将内容返回给客户端.称为rewrite. 2 客户端重定向 客户端想要访问的内容不在该 ...
- servlet,RMI,webservice之间的区别
最近项目中有提供或者调用别的接口,在纠结中到底是用servlet还是用webservice,所以上网查看了下他们以及RMI之间的区别,方便加深了解. 首先比较下servlet和webservice下 ...
- BootstrapValidator demo
source:http://bv.doc.javake.cn/api/ BootstrapValidator is the best jQuery plugin to validate form fi ...