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 app安全问题设置
1.应用签名未校验风险:检测 App 程序启动时是否校验签名证书. 2.应用数据任意备份风险 Android 2.1 以上的系统可为 App 提供应用程序数据的备份和恢复功能,该 由 AndroidM ...
- Java模拟post-get提交
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import ...
- ansible module
模块是一个独立的, 可以复用的脚本, 它可以被anisible API, Ansible 或者ansible-playbook使用. 在模块退出之前, 它通过输出一个json字符串到标准输出从而反 ...
- HTTP Response Splitting攻击探究 <转>
第一小节:HTTP Basics:使用Proxy软件(例如Webscarab)来截断浏览器(客户端)和Server之间的HTTP通信,之后任意篡改得到预期结果即可. 第二小节:HTTP Splitti ...
- "The Application was unable to start correctly (0xc000007b). Click OK to close the application"
我有时将MFC编译成64位并运行,就会报这个错误. 后来查找原因,就在于系统中使用了错误的dll.比如这个程序要使用64位的dll,而你拷贝进去的是同名的32位dll.解决方法就是放置正确的dll. ...
- 链表中LinkList L与LinkList *L 借鉴
链表中LinkList L与LinkList *L的区别以及(*L).elem,L.elem L->next,(*L)->next的区别typedef struct Node{int el ...
- Egret 学习之简介,环境搭建及命令行语法 (一)
1,简介 1)egret是一个开源免费的游戏框架,它使用TypeScript脚本语言进行开发:当游戏完成最终的打包后,可以将程序转换为h5游戏,实现跨平台性:它基于BSD(Berkly Softwar ...
- 在GNU/Linux下使用命令行自动挂载与卸载USB磁盘
在命令行环境下如果每次都是靠手动敲入mount与umount命令来挂载与卸载USB磁盘是件很麻烦的事情.尤其是mount命令的参数非常多.比如,磁盘的分区类型(vfat.ntfs等),挂载的目录节点, ...
- for i in xrange(0,5)使用过程中遇到的问题
文件中共有4行内容. fd = open("C:\Users\william\Desktop\dup_file - Copy (2).txt")for i in xrange(0, ...
- lucene 总结收集(url)
1.倒排索引结构 2.lucene自定义评分域 3.Lucene系列-FieldCache 4.Lucene系列-facet | IT瘾 5.lucene4.7 之排序 6.lucene排序---相关 ...