-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgramaTvN3
50 lines (43 loc) · 1.04 KB
/
ProgramaTvN3
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
/*
Timing = {
"reading": "3:36",
"coding": "15:16",
"total": 18:52
};
*/
#include <bits/stdc++.h>
#define MAX 3005
using namespace std;
vector< pair< pair<int,int>, int> > lista(MAX);
vector< int > winlist;
int x,y,z,c,s,m;
int ng=0, maxp=0, nmaxp=0;
void bt(int pos, int pasos, int dinero){
if(pasos >= m){
if(find(winlist.begin(), winlist.end(), pos) != winlist.end()){
ng++;
if(dinero > maxp){
maxp=dinero;
nmaxp=1;
} else if(dinero == maxp)
nmaxp++;
}
return;
}
bt(lista[pos].first.first, pasos+1, dinero+lista[pos].second);
bt(lista[pos].first.second, pasos+1, dinero);
}
int main(){
ifstream fin("in.txt");
fin >> c >> s >> m;
for(int i=1;i<=c;i++){
fin >> x >> y >> z;
lista[i]= make_pair( make_pair(x,y) , z );
}
for(int i=1;i<=s;i++){
fin >> x;
winlist.push_back(x);
}
bt(1,0,0);
cout << ng << ' ' << maxp << ' ' << nmaxp << endl;
}