forked from chr4ss1/SPOJ
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCLASSICO.cpp
More file actions
52 lines (41 loc) · 1.09 KB
/
CLASSICO.cpp
File metadata and controls
52 lines (41 loc) · 1.09 KB
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
int players[2000];
int player_count;
vector<int> pick_best_team(int players_left, int players_to_pick)
{
// basecase!
if(!players_to_pick || !players_left)
return vector<int>();
// how many indexes can we consider?
int best_choice = 0;
int start_index = player_count - players_left;
for(int j = 1; j <= players_left - players_to_pick; j++){
if(players[start_index + j] > players[start_index + best_choice])
best_choice = j;
}
vector<int> result = pick_best_team(players_left - best_choice - 1, players_to_pick - 1);
result.insert(result.begin(), players[start_index + best_choice]);
return result;
}
int main() {
int t;
scanf("%d", &t);
for(int c = 1; t; t--, c++){
scanf("%d", &player_count);
for(int j = 0; j < player_count; j++)
scanf("%d", &players[j]);
if(player_count < 11){
printf("Case %d: go home!\n", c);
continue;
}
// start raping this shit.
printf("Case %d: ", c);
vector<int> res = pick_best_team(player_count, 11);
for(int k = 0; k < res.size(); k++){
if(k > 0)
printf(" ");
printf("%d", res[k]);
}
printf("\n");
}
return 0;
}