uva 231 - Testing the CATCHER Solution

uva 231 - Testing the CATCHER Solution


#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;

vector<int> list;

int getMaxMissiles(){
long long len = list.size(),i,j,max=1;
long long *count = new long long[len];
fill(count, count + len, 1);
for (i = 1; i < len; i++){
for (j = 0; j < i; j++){
if (list[i] < list[j]){
if (count[j] + 1>count[i]){
count[i] = count[j] + 1;
if (max < count[i])
max = count[i];
}
}
}
}
return max;
}

int main(){
int x;
long long kk = 1;
while (cin >> x){
if (x == -1)
break;
list.clear();
list.push_back(x);
while (cin >> x){
if (x == -1)
break;
list.push_back(x);
}
if (kk != 1)
cout << endl;

cout << "Test #" << kk++ << ":" << endl << "  maximum possible interceptions: " << getMaxMissiles() << endl;
}
return 0;
}

Comments

Popular posts from this blog

uva 679 - Dropping Balls Solution

uva 481 - What Goes Up Solution

uva-10077 Solution --- The Stern-Brocot Number System