Ultraviolet (a) problem 111-history grading

Source: Internet
Author: User
Tags dot net
// Va problem 111-history grading // verdict: accepted // submission date: 2011-11-25 // ultraviolet Run Time: 0.052 S // copyright (c) qiu, 2011. Metaphysis # Yeah dot net // [solution] // you can convert the problem to the problem of the longest ascending subsequence. # Include <iostream> # include <sstream> using namespace STD; # define maxn 25int order [maxn], events [maxn], length [maxn], n; int getscores (void) {for (INT I = 1; I <= N; I ++) length [I] = 1; for (INT I = 1; I <= N; I ++) for (Int J = 1; j <I; j ++) if (events [J] <events [I] & (length [J] + 1)> length [I]) length [I] = length [J] + 1; int maxlength = 1; for (INT I = 1; I <= N; I ++) maxlength = max (maxlength, length [I]); Return maxlength;} int getindex (INT index) {for (INT I = 1; I <= N; I ++) if (Order [I] = index) return I;} int main (INT argc, char const * argv []) {string line; int index; CIN> N; for (INT I = 1; I <= N; I ++) {CIN> index; Order [Index] = I;} cin. ignore (); While (Getline (CIN, line) {istringstream ISS (line); For (INT I = 1; I <= N; I ++) {ISS> index; events [Index] = getindex (I) ;}cout <getscores () <Endl ;}return 0 ;}

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.