알고리즘 역량테스트 문제/SWEA
[SWEA][D3][c++] 6913. 동철이의 프로그래밍 대회
coooding
2020. 7. 18. 13:16
문제
6913. 동철이의 프로그래밍 대회
문제 링크
https://swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AWicMVWKTuMDFAUL
SW Expert Academy
SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!
swexpertacademy.com
풀이 과정
1. 입력값을 받으며 참가자의 점수를 계산한다.
2. 참가자의 점수계산 점수의 최대값(1등) 점수를 갱신한다.
3. 최대값인 참가자가 몇명인지 계산한다.
4. 최대값과 1등 참가자들을 출력한다.
코드
#include<iostream>
using namespace std;
int main()
{
cin.tie(0);
cout.tie(0);
cout.sync_with_stdio(false);
int test_case;
int T,N,M,max,victory;
cin>>T;
int score[20];
for(test_case = 1; test_case <= T; ++test_case)
{
cin >> N >> M;
int temp;
max=0 , victory=0;
for(int i=0; i<N; i++){
score[i]=0;//초기화
for(int j=0; j<M; j++){
cin >> temp;
score[i]+=temp;
}
if(score[i]>max)
max=score[i];//최대값 갱신
}
for(int i=0; i<N; i++){
if(score[i]==max)
victory++;//1등 수
}
cout <<"#"<<test_case<<" "<<victory<<" "<<max<<"\n";
}
return 0;
}