CodeForces 605A Sorting Railway Cars 思维】的更多相关文章

早起一水…… 题意看着和蓝桥杯B组的大题第二道貌似一个意思…… 不过还是有亮瞎双眼的超短代码…… 总的意思呢…… 就是最长增长子序列且增长差距为1的的…… 然后n-最大长度…… 这都怎么想的…… 希望今天的省选可以亮光乍现~~~ #include<stdio.h> #include<iostream> #include<string.h> #include<algorithm> #include<math.h> using namespace s…
求一下最长数字连续上升的子序列长度,n-长度就是答案 O(n)可以出解,dp[i]=dp[i-1]+1,然后找到dp数组最大的值. #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> using namespace std; const int INF=0x7FFFFFFF; +; int dp[maxn]; int n,x; int main() { while(~s…
time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output An infinitely long railway has a train consisting of n cars, numbered from 1 to n (the numbers of all the cars are distinct) and positioned…
Description An infinitely long railway has a train consisting of n cars, numbered from 1 to n (the numbers of all the cars are distinct) and positioned in arbitrary order. David Blaine wants to sort the railway cars in the order of increasing numbers…
Description An infinitely long railway has a train consisting of n cars, numbered from 1 to n (the numbers of all the cars are distinct) and positioned in arbitrary order. David Blaine wants to sort the railway cars in the order of increasing numbers…
其实就是求总长度 - 一个最长“连续”自序列的长度 最长“连续”自序列即一个最长的lis,并且这个lis的值刚好是连续的,比如4,5,6... 遍历一遍,贪心就是了 遍历到第i个时,此时值为a[i],如果a[i]-1在前面已经出现过了,则len[a[i]] = len[a[i-1]]+1 否则len[a[i]] = 1 #include <cstdio> #include <algorithm> #include <cstring> #include <iostr…
C. Sorting Railway Cars Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://www.codeforces.com/contest/606/problem/C Description An infinitely long railway has a train consisting of n cars, numbered from 1 to n (the numbers of all the cars are distin…
C. Sorting Railway Cars   An infinitely long railway has a train consisting of n cars, numbered from 1 to n (the numbers of all the cars are distinct) and positioned in arbitrary order. David Blaine wants to sort the railway cars in the order of incr…
C. Sorting Railway Cars time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output An infinitely long railway has a train consisting of n cars, numbered from 1 to n (the numbers of all the cars are d…
C. Sorting Railway Cars time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output An infinitely long railway has a train consisting of n cars, numbered from 1 to n (the numbers of all the cars are d…