Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdio>
- #include <algorithm>
- #include <cstring>
- #include <string>
- #include <cctype>
- #include <stack>
- #include <queue>
- #include <list>
- #include <vector>
- #include <map>
- #include <set>
- #include <sstream>
- #include <stdlib.h>
- #include <cmath>
- #define FOR(i,A) for(typeof (A).begin() i = (A).begin() ; i != (A).end() ; i++)
- #define debug( x ) cout << #x << " = " << x << endl
- #define clr(v,x) memset( v, x , sizeof v )
- #define all(x) (x).begin() , (x).end()
- #define rall(x) (x).rbegin() , (x).rend()
- #define TAM 110
- using namespace std;
- typedef pair<int,int> ii ;
- typedef long long ll ;
- typedef long double ld ;
- typedef pair<int,ii> pii ;
- int arr[101][101];
- int aux,aux1;
- bool cmp(const ii &a ,const ii &b){
- return ((a.second)<(b.second));
- }
- int main() {
- int G,P;
- while(scanf("%d %d",&G,&P)){
- if(G==0 && P==0) break;
- for(int i=0;i<G;i++){
- for(int j=0;j<P;j++){
- scanf("%d",&arr[i][j]);
- }
- }
- int s;scanf("%d",&s);
- for(int i=0;i<s;i++){
- scanf("%d",&aux);map<int,int> mp;
- for(int j=1;j<=aux;j++){
- scanf("%d",&aux1);
- mp[j]=aux1;
- }
- map<int,int> mp1;/*columna del jugador con puntos*/
- for(int j=1;j<=P;j++) mp1[j+1]=0;
- for(int k=0;k<G;k++){
- for(int j=0;j<P;j++){
- if(mp.count(arr[k][j])==0){/*no existe puntaje para puesto*/
- continue;
- }else{
- mp1[j+1]+=mp[arr[k][j]];
- }
- }
- }
- /*proceso de impresion*/
- vector<ii> v;ii par;
- map<int,int> ::iterator it;int maxi=0;
- for(it=mp1.begin();it!=mp1.end();it++){
- par.first=it->first;par.second=it->second;
- v.push_back(par);
- }
- sort(v.begin(),v.end(),cmp);vector <int> auxi;
- maxi=v[v.size()-1].second;auxi.push_back(v[v.size()-1].first);
- for(int j=v.size()-2;j>=0;j--){
- if(v[j].second==maxi) auxi.push_back(v[j].first);
- else break;
- }
- sort(auxi.begin(),auxi.end());
- if(auxi.size()==1) printf("%d\n",auxi[0]);
- else{
- for(int j=0;j<auxi.size();j++){
- if(j!=auxi.size()-1) printf("%d ",auxi[j]);
- else printf("%d\n",auxi[j]);
- }
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement