`
200830740306
  • 浏览: 106402 次
  • 性别: Icon_minigender_1
  • 来自: 广州
社区版块
存档分类
最新评论

poj2533

阅读更多
package easy;


import java.io.BufferedInputStream;
import java.util.Scanner;

/**
 *
 *poj2533
 * 注意是递增序列,不是非递减
 * @author NC
 */
public class Poj2533 {

    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedInputStream(System.in));
        if (scan.hasNext()) {
            int n = scan.nextInt();
            int[] data = new int[n];
            int[] count = new int[n];
            for (int i = 0; i < n; i++) {
                int a = scan.nextInt();
                data[i] = a;
                count[i] = 1;
                int max = count[i];
                int flag = 0;
                for (int j = i - 1; j >= 0; j--) {
                    if (data[i] > data[j]) {
                        if (count[j] > max) {
                            max = count[j];
                        }//之前想错了,应该是当前最长。要全部比较一次
                        flag = 1;
                    }
                }
                if (flag == 1) {
                    count[i] = max + 1;
                }
            }
            int max = count[0];
            for (int i = 1; i < n; i++) {
                if (count[i] > max) {
                    max = count[i];
                }
            }
            System.out.println(max);
        }
    }
}


分享到:
评论

相关推荐

    POJ2533-Longest Ordered Subsequence

    北大POJ2533-Longest Ordered Subsequence 解题报告+AC代码

    北大POJ2533-Longest Ordered Subsequence【O(nlogn)】

    北大POJ2533-Longest Ordered Subsequence【O(nlogn)】

    北大POJ2533-Longest Ordered Subsequence【O(n^2)】

    北大POJ2533-Longest Ordered Subsequence【O(n^2)】

    poj题目分类

    * 类型 DP:例如 poj3267、poj1836、poj1260、poj2533。 中级 1. 基本算法: * C++的标准模版库的应用:例如 poj3096、poj3007。 * 较为复杂的模拟题的训练:例如 poj3393、poj1472、poj3371、poj1027、poj2706...

    LeetCode判断字符串是否循环-Leetcode:刷!

    2533 POJ 1836 Leetcode 70 Leetcode 309 搜索 DFS POJ 2488 POJ 3083 POJ 3009 POJ 1321 BFS POJ 3278 POJ 1426 POJ 3126 POJ 3414 POJ 2251 简单搜索技巧和剪枝 POJ 1010 :star: POJ 2362 POJ 1011(搜索+剪枝) ...

    poj部分源码--Java

    poj平台有关数据结构题的Java源码 1159 1276 2406 2502 2509 2513 2533 2778 3176

    北大POJ部分题目答案(一些基础题目)

    很多的POJ题目答案!1000~1008,1011~1014,1016,1017,1019,1028,1032,1045,1046,1047,1050,1061,1067,1068,1088,1102,1159,1163,1183,1207,1218,1226,1247,1256,1258,1298,1316,1323,...

    poj经典动态规划题目解题报告

    poj经典动态规划题目解题报告,包括经典的动态规划题目20多道,可以作为学习动态规划系统的资料,包括题目: Pku acm 1179 Polygon Pku acm 1125 Stockbroker Grapevine Pku acm 1160 post office Pku ...

    acm poj 源代码

    1001 1002 1003 1004 1005 1006 1007 1008 1011 1012 1013 1014 1015 1017 ...2533 2538 2545 2550 2551 2560 2591 2593 2601 2608 2626 2636 2643 2656 2663 2665 2676 2752 2817 2853 2965 3034 3062 3100 3176 3199 ...

    poj pku 解题报告

    1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1011 1012 1013 1014 ...2533 2545 2553 2559 2564 2575 2576 2586 2591 2593 2594 2602 2623 2632 2656 2676 2680 2707 2750 2774 2777 2780 2782 2812 2818 2840 ...

Global site tag (gtag.js) - Google Analytics