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 ...
随机推荐
- php dday1... web服务器的搭建 数据库的安装....
- ios在项目中打开word文档、ppt等总结
最近在项目开发中遇到下载附件文档预览需求,在这里总结一下我的实现方法,本文最后会附带我写的demo下载地址 这里我总结了三种实现方法(1)用webView预览(2)通过UIDocumentIntera ...
- Duilib使用wke显示echarts
不得不说wke是个简洁好用的浏览器内核.网上很多大神已经把wke嵌入到duilib中了,先感谢他们辛勤的工作.这里通过wke吧C++的数据在ECharts上美观的显示出来.借鉴前人,将ECharts进 ...
- 51nod1092(lcs简单运用/dp)
题目链接:https://www.51nod.com/onlineJudge/questionCode.html#!problemId=1092 题意:中文题诶- 思路: 解法1:最坏的情况就是在原字 ...
- IOS Android支持中文与本地文件的读取写入
转自http://www.xuanyusong.com/archives/1069 和http://www.benmutou.com/archives/2094 前几天有个朋友问我为什么在IOS平台中 ...
- hdu 2829 Lawrence(斜率优化DP)
题目链接:hdu 2829 Lawrence 题意: 在一条直线型的铁路上,每个站点有各自的权重num[i],每一段铁路(边)的权重(题目上说是战略价值什么的好像)是能经过这条边的所有站点的乘积之和. ...
- PHP短信发送服务 youe短信企业服务
/** * 通用短信平台HTTP接口POST方式发送短信实例 * 返回字符串 * 一般情况下调用此方法 */ function postSendMessage($msgContents,$phoneL ...
- Python基础(七)-文件操作
一.文件处理流程 1.打开文件,得到文件句柄赋值给一个变量 2.通过句柄对文件进行操作 3.关闭文件 二.基本操作 f = open('zhuoge.txt') #打开文件 first_line = ...
- Linux 网络性能tuning向导
本文的目的不完全在于提供调优信息,而是在于告诉读者了解Linux kernel如何处理数据包,从而能够在 自己的实践中发挥Linux 内核协议栈最大的性能 The NIC ring buffer 接收 ...
- VHDL设计问题
在做算术运算的时候,不可以用std_ulogic_vector,必须是std_logic_vector.