POJ - 2533 Longest Ordered Subsequence(最长上升子序列)
2015-09-26 10:41
429 查看
题目大意:求最长上升子序列
解题思路:裸题
解题思路:裸题
[code]#include <cstdio> #include <cstring> const int N = 1010; int num ; int n; int find(int r, int t) { int l = 0, mid; while (l < r) { int mid = (l + r) / 2; if (num[mid] < t) l = mid + 1; else r = mid; } return r; } void solve() { int top = 0, t; num[0] = -1; for (int i = 0; i < n; i++) { scanf("%d", &t); if (t > num[top]) num[++top] = t; else num[find(top, t)] = t; } printf("%d\n", top); } int main() { while (scanf("%d", &n) != EOF) solve(); return 0; }
相关文章推荐
- Android UI之ListView+CheckBox(避免抢占焦点)
- POJ - 1458 Common Subsequence(最长公共子序列)
- Hbuilder 常用快捷键汇总
- Android UI之ViewPager
- String,StringBuffer,StringBuild的区别
- dispatch_async和dispatch_sync在dispatch_get_main_queue上的区别
- leetcode 270: Closest Binary Search Tree Value
- EasyUI刷新tab的页面
- UI基础知识
- ios8 UITableVIewCell 侧滑显示多个按钮
- hdu 1242 Rescue(方法一:BFS+优先队列,方法二:DFS)
- UCGUI编程一:文本显示模式
- 【UIKit-125-4】#import <UIKit/UIViewController.h>
- IOS TableView的Cell高度自适应,UILabel自动换行适应
- hdu4740The Donkey of Gui Zhou dfs水题
- UEFI 装 Debian
- HDU-1560 DNA sequence
- iOS多线程编程之NSOperation和NSOperationQueue的使用
- iOS项目开发实战——UILabel自适应较多的文本
- easyui validatebox 验证类型