Poj 1887 testing the catcher

Source: Internet
Author: User
// I can't believe it. This is the second question of world finals 1994, that is, the simple Lis practice, but there are a lot of things to be aware of, and it needs to be very careful, // you must be able to understand the question! This question uses binary + dp, 0 ms, and the data is still relatively weak! // Both methods for solving LIS are written. The efficiency of the first method is significantly higher than that of the second method. The time complexity of the first method is O (n ^ 2 ), the second time complexity is O (nlgn )! # Include <iostream> # include <memory. h> using namespace STD; int height [100000], TMP [100000]; int main () {int I, n = 0, temp, Tc = 0, ANS = 0, left, right, mid; bool flag = false; while (CIN> temp) {If (temp =-1 & flag) {break ;} else if (temp =-1 &&! Flag) {TC ++; TMP [0] = 32768; for (I = 0; I <n; I ++) {If (height [I] <TMP [ANS]) {TMP [++ ANS] = height [I];} else {left = 1, Right = ans; while (left <= right) {mid = (left + right)/2; If (TMP [Mid]> height [I]) {left = Mid + 1 ;} else {right = mid-1 ;}} TMP [left] = height [I] ;}} cout <"test #" <tc <": "<Endl; cout <" maximum possible interceptions: "<ans <Endl; ans = n = 0; memset (TMP, 0, sizeof (TMP); flag = true;} else {height [N] = temp; n ++; flag = false ;}} system ("pause");}/* # include <iostream> # include <memory. h> using namespace STD; int height [100000], DP [100000]; int main () {int I, j, n = 0, temp, Tc = 0, ans = 0; bool flag = false; while (CIN> temp) {If (temp =-1 & flag) {break ;} else if (temp =-1 &&! Flag) {TC ++; for (I = 0; I <100000; I ++) DP [I] = 1; for (I = 1; I <N; I ++) {for (j = 0; j <I; j ++) {If (height [I] 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.