"Topic link"
Http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=114&page=show_ problem&problem=47
"History Grading
Background
Many problems in Computer, involve maximizing some measure according to constraints.
Consider a history exam in which students are the to put asked several events into the historical order. Students who order all the events correctly'll receive full credit, but and should partial credit is awarded to Students Who incorrectly rank one or more of the historical events?
Some possibilities for partial credit include:
1 point for each event whose rank matches its correct rank
1 point for each event in the longest (not necessarily contiguous) sequence of events which are in the correct order Relat Ive to the other.
For example, if four events are correctly ordered 1 2 3 4 then the Order 1 3 2 4 would receive a score of 2 using the Firs T method (events 1 and 4 are correctly ranked) and a score of 3 using the second method (event sequences 1 2 4 and 1 3 4 A Re both in the correct order relative
In this problem your are asked to write a, to score such questions using the second method.
The Problem
Given the correct chronological order of N events
As
where
Denotes the ranking of eventi in the correct chronological order and a sequence of student
where
This column more highlights: http://www.bianceng.cn/Programming/sjjg/
denotes the chronological rank given by the student to event I; Determine the length of the longest (not necessarily contiguous) sequence of events in the student responses this are in T He correct chronological the order of relative to the other.
The Input
The ' the ' of ' input'll consist of one integer n indicating the number of events with
. The second line would contain n integers, indicating the correct chronological order of n events. The remaining lines'll each consist of nintegers with each line representing a student ' s chronological ordering of the N Events. All lines'll contain n numbers in the range
, with each number appearing exactly once/, and with each number separated from other numbers on the same line by One or more spaces.
The Output
For each student ranking of the events your program should print the score for that ranking. There should be one of the output for each student ranking.
Sample Input 1
4
4 2 3 1 1 3 2 4 3 2 1 4 2 3 4-1
Sample Output 1
1
2
3
Sample Input 2
Ten
3 1 2 4 9 5 6 8 7 1 2 3 4 5 6 7 8 9 4 7 2 3 6 9 1 5 8 3 1 A
4 9 5 7 6
Sample Output 2
6
5
9