CodeForces 605A Sorting Railway Cars 思维
早起一水……
题意看着和蓝桥杯B组的大题第二道貌似一个意思……
不过还是有亮瞎双眼的超短代码……
总的意思呢……
就是最长增长子序列且增长差距为1的的……
然后n-最大长度……
这都怎么想的……
希望今天的省选可以亮光乍现~~~
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<algorithm>
#include<math.h>
using namespace std;
int a[];
int b[];
int main(){
int n;
while(~scanf("%d",&n)){
a[]=;
for(int i=;i<=n;i++){
scanf("%d",&a[i]);
b[a[i]]=b[a[i]-]+;
}
sort(b+,b+n+);
printf("%d\n",n-b[n]);
}
return ;
}
CodeForces 605A Sorting Railway Cars 思维的更多相关文章
- CodeForces 605A Sorting Railway Cars
求一下最长数字连续上升的子序列长度,n-长度就是答案 O(n)可以出解,dp[i]=dp[i-1]+1,然后找到dp数组最大的值. #include<cstdio> #include< ...
- Codeforces 335C Sorting Railway Cars
time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standa ...
- [Codeforces 606C]Sorting Railway Cars
Description An infinitely long railway has a train consisting of n cars, numbered from 1 to n (the n ...
- CodeForces 606C Sorting Railway Cars(最长连续上升子序列)
Description An infinitely long railway has a train consisting of n cars, numbered from 1 to n (the n ...
- cf 605A Sorting Railway Cars 贪心 简单题
其实就是求总长度 - 一个最长“连续”自序列的长度 最长“连续”自序列即一个最长的lis,并且这个lis的值刚好是连续的,比如4,5,6... 遍历一遍,贪心就是了 遍历到第i个时,此时值为a[i], ...
- Codeforces Round #335 (Div. 2) C. Sorting Railway Cars 动态规划
C. Sorting Railway Cars Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://www.codeforces.com/conte ...
- Codeforces Round #335 (Div. 2) C. Sorting Railway Cars 连续LIS
C. Sorting Railway Cars An infinitely long railway has a train consisting of n cars, numbered from ...
- Codeforces 606-C:Sorting Railway Cars(LIS)
C. Sorting Railway Cars time limit per test 2 seconds memory limit per test 256 megabytes input stan ...
- Codeforces Round #335 (Div. 2) C. Sorting Railway Cars
C. Sorting Railway Cars time limit per test 2 seconds memory limit per test 256 megabytes input stan ...
随机推荐
- android下拉刷新控件 android-pulltorefresh
运行效果: 介绍:ListView.ViewPager.WevView.ExpandableListView.GridView.(Horizontal)ScrollView.Fragment上下左右拉 ...
- Unity启动事件-监听:InitializeOnLoad
[InitializeOnLoad] :在启动Unity的时候运行编辑器脚本 官方案例: using UnityEngine; using UnityEditor; [InitializeOnLoa ...
- MyBatis-Generator 逆向工程(生成异常缺少部分的方法)
今日在使用 MyBatis-Generator 逆向工程时遇到了生成 mapper.java , mapper.xml 时缺少部分方法. 正常的 Mapper.java 示例: public in ...
- 关于IIS和.NET 4.0的问题总结(转)
注册asp.net 4.0 到iis 如果没有按照正常的先装iis后装.net的顺序,可以使用此命令重新注册一下 运行->cmd Microsoft Windows [版本 6.1.7601 ...
- 调皮的R文件,卑鄙的空格
毕业快一年了,由于公司业务需要,开发岗的我做了一年测试.最近,终于要开始转开发了.于是和小伙伴们合作,做一个备忘录apk.由于之前是做java的,而且差不多一年没碰代码了(这一年主要做测试,虽然有写自 ...
- 怎么 得到 DBGrid选中行的数据
转自:https://zhidao.baidu.com/question/1694035814426308148.html 一般是你鼠标点到哪一行,其DataSet的指针就指到了什么位置你可以直接通过 ...
- SQL Server2012中的SequenceNumber
http://www.cnblogs.com/CareySon/archive/2012/03/12/2391581.html https://q.cnblogs.com/q/53552/ https ...
- iOS-OC对象模型
原文:http://blog.csdn.net/fanyiyao980404514/article/details/44864663 在C++的内存模型中我们知道,我们通过虚函数列表来存储虚函数的虚拟 ...
- Flash cc 添加目标Flash Player
原文出处:http://zengrong.net/post/1568.htm 第一步 首先下载最新的 playerglobal.swc(基于Flash Player11): http://www.ad ...
- python2与python3
一.print python2 print "hello world !" python3 print("hello world!") 二.字符编码 pyth ...