A. A Prank
题意
有数列从小到大排列,都是不同范围1~ 1000,问你最多去掉多少个数字还能复原
由于wrong很多发所以写一下
链接
[http://codeforces.com/contest/1062/problem/A]
分析
坑爹的是注意从1开始,和1000结尾的那两段
其他枚举
代码
#include<bits/stdc++.h>
using namespace std;
#define N 100000+5
int a[N];
int main()
{
int i, j, k;
int n, m;
cin>>n;
for(i=0; i<n; i++)
cin>>a[i];
int co=0, maxn=0;
for(i=0; i<n; i++)
{
if(!i && a[i+1]==2)
co++;
else if(i==n-1 && a[n-2]==999)
co++;
else
{
if(a[i]==a[i-1]+1 && a[i]==a[i+1]-1)
co++;
else maxn=max(maxn, co), co=0;
}
}
maxn=max(maxn, co);
cout<<maxn<<endl;
return 0;
}
A. A Prank的更多相关文章
- Codeforces1062A. A Prank(暴力)
题目链接:传送门 题目: A. A Prank time limit per test second memory limit per test megabytes input standard in ...
- Codeforces Round #520 (Div. 2) A. A Prank
A. A Prank time limit per test 1 second memory limit per test 256 megabytes 题目链接:https://codefo ...
- codeforces#1152D. Neko and Aki's Prank(dp)
题目链接: https://codeforces.com/contest/1152/problem/D 题意: 给出一个$n$,然后在匹配树上染色边,每个结点的所有相邻边只能被染色一次. 问,这颗树上 ...
- Neko and Aki's Prank CodeForces - 1152D (括号序列,dp)
大意: 将所有长度为2*n的合法括号序列建成一颗trie树, 求trie树上选出一个最大不相交的边集, 输出边集大小. 最大边集数一定不超过奇数层结点数. 这个上界可以通过从底层贪心达到, 所以就转化 ...
- Codeforce Round #554 Div.2 D - Neko and Aki's Prank
dp 找规律 我好菜啊好菜啊,完全没有思路. 在合法的括号序列中,左括号数一定大于等于右括号数的,所以我们可以先定义平衡度为左括号数-右括号数. 然后可以发现一个惊人的规律..就是在trie同一深度上 ...
- CodeForces 1152D Neko and Aki's Prank
说明 Catalan(i) 表示卡特兰数的第 i 项. 题目链接:http://codeforces.com/problemset/problem/1152/C 题目大意 有 n 个左括号和 n 个右 ...
- [Evolutionary Algorithm] 进化算法简介
进化算法,也被成为是演化算法(evolutionary algorithms,简称EAs),它不是一个具体的算法,而是一个“算法簇”.进化算法的产生的灵感借鉴了大自然中生物的进化操作,它一般包括基因编 ...
- hdu 1232, disjoint set, linked list vs. rooted tree, a minor but substantial optimization for path c 分类: hdoj 2015-07-16 17:13 116人阅读 评论(0) 收藏
three version are provided. disjoint set, linked list version with weighted-union heuristic, rooted ...
- javascript --- Function模式
回调函数 在javascript中,当一个函数A作为另外一个函数B的其中一个参数时,则称A函数为回调函数,即A可以在函数B的运行周期内执行(开始,中间,结束). 举例来说,有一个函数用于生成node. ...
随机推荐
- centos7执行umount提示:device is busy或者target is busy解决方法
问题描述: 因为挂载错了,想取消挂载,但是umount报告如下错误: [root@zabbix /]# umount /dev/sdc1 umount: /data1: target is busy. ...
- Head First Android --- Intent
How to create the intentYou create an intent that specifies an action using the following syntax:whe ...
- ghostscript远程代码执行漏洞复现
这两天网上ghostscript又又有漏洞信息了,但是没有poc,于是找找资料把今年8月21日的那个验证下 1.关于ghostscript Ghostscript是一套建基于Adobe.PostScr ...
- 第 16 章 C 预处理器和 C 库(qsort() 函数)
/*---------------------------------------- qsorter.c -- 用 qsort() 排序一组数字 --------------------------- ...
- Linux 小知识翻译 - 「协议(protocol)」
对于理解服务器和网络来说,「协议」是不可缺少的概念. 「协议(protocol)」有「规则,规定」的意思. 实际上「协议」的函数很广,在通信领域,「协议」规定了「在通信时,什么样的情况下,以什么样的顺 ...
- java中的深复制和浅复制
Java 语言的一个优点就是取消了指针的概念,但也导致了许多程序员在编程中常常忽略了对象与引用的区别,本文会试图澄清这一概念.并且由于Java不能通过简单 的赋值来解决对象复制的问题,在开发过程中,也 ...
- 寒假集训——搜索 B - Sudoku
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <iostream&g ...
- vue.js 防暴力点击方案
import lodash from 'lodash' <input v-on:onclick ="doStuff">methods: { doStuff:loadsh ...
- k8s调度的亲和性和反亲和性
文章转自 http://ju.outofmemory.cn/entry/278349 https://www.jianshu.com/p/102c4df69af9 RequiredDuringSche ...
- 分布式缓存技术redis系列(五)——redis实战(redis与spring整合,分布式锁实现)
本文是redis学习系列的第五篇,点击下面链接可回看系列文章 <redis简介以及linux上的安装> <详细讲解redis数据结构(内存模型)以及常用命令> <redi ...