Created
January 6, 2016 10:52
-
-
Save abrarShariar/bd0460817836e4472d4d to your computer and use it in GitHub Desktop.
Find The Winner (SPOJ) - Programming Problem
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Problem statement : http://www.spoj.com/problems/FINDWINNER/ | |
//SOLVING NOW | |
#include<iostream> | |
int main(){ | |
int testCase; | |
std::cin>>testCase; | |
for(int t=0;t<testCase;t++){ | |
int numP,numR,input; | |
std::cin>>numP>>numR; | |
int matrix[numR][numP]; | |
//initializing | |
for(int i=0;i<numR;i++){ | |
for(int j=0;j<numP;j++){ | |
std::cin>>input; | |
matrix[i][j]=input; | |
} | |
} | |
int maxScore=0; | |
for(int i=0;i<numP;i++){ | |
int sum=0; | |
for(int j=0;j<numR;j++){ | |
sum=sum+matrix[j][i]; | |
} | |
if(sum>maxScore){ | |
maxScore=sum; | |
} | |
//cout<<sum<<endl; | |
} | |
std::cout<<maxScore<<std::endl; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment