-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVendedorasN2
60 lines (51 loc) · 1.21 KB
/
VendedorasN2
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
//Timing: 27:17
#include <bits/stdc++.h>
#define MAX 10000
using namespace std;
int n,a,b,c,temp, maxg, w;
bool empate;
vector< vector< int > > lista(MAX);
pair<int,int> gw(int c){
maxg = 0; temp = 0; w = 0;
empate=true;
for(int i=1;i<=n;i++){
if(lista[i].size() >= c){
empate=false;
if(lista[i][c-1] > maxg){
temp=1;
maxg = lista[i][c-1];
w=i;
} else if(lista[i][c-1] == maxg)
temp++;
}
}
if(empate)
return make_pair(-1,-1);
if(temp > 1)
return gw(c+1);
if(temp == 1)
return make_pair(w, c);
return make_pair(0,0);
}
int main(){
ifstream fin("in.txt");
fin >> n;
for(int i=1;i<=n;i++){
fin >> a;
temp = 0;
for(int j=1;j<=a;j++){
fin >> b;
temp+=b;
lista[i].push_back(temp);
}
}
int v;
fin >> v;
pair<int,int> t = gw(v);
if(t.first == 0)
cout << "No hay ganadoras" << endl;
else if(t.first == -1)
cout << "No se puede desempatar" << endl;
else
cout << t.first << endl << t.second << ' ' << lista[t.first][t.second-1] << endl;
}