-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCATCHER.cpp
68 lines (56 loc) · 1.28 KB
/
CATCHER.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <set>
#include <string>
#include <vector>
using namespace std;
ifstream fin("CATCHER.in");
ofstream fout("CATCHER.out");
int main()
{
int testCase = 0;
while (true)
{
++testCase;
vector<int> missile;
int in;
while (true)
{
fin >> in;
if (in == -1)
{
break;
}
missile.push_back(in);
}
int size = missile.size();
if (size == 0)
{
break;
}
vector<int> dp(size);
for (int i = 0; i <= size - 1; ++i)
{
dp[i] = 1;
for (int j = 0; j <= i - 1; ++j)
{
if (missile[j] >= missile[i])
{
dp[i] = max(dp[i], dp[j] + 1);
}
}
}
auto it = max_element(dp.begin(), dp.end());
if (testCase > 1)
{
fout << '\n';
}
fout << "Test #" << testCase << ":\n maximum possible interceptions: " << *it << '\n';
}
return 0;
}