# TugOfWar/이승한¶

150/200 빼고는 답이 나오긴 하지만. 분명히 틀린 알고리즘.
급기야는 오류가 보이자 땜빵으로 매꿔버리기도 하고...-_-ㅋ;;
```~cpp
#include <iostream>
using namespace std;

const int MAX= 100;

int maxToZero(int input[]); //가장큰수를 0로 바꾸어주는 함
int returnAver(int input[]);

void main(){

int weight[MAX] =	{0};
int outA[MAX]	=	{0};
int outB[MAX]	=	{0};

int teamA, teamB;
teamA = teamB	=	0;

int aver		=	0;
int maxInInput	=	0;
int N			=	0;
int inputN		=	0;
int input		=	0;

int A, B;
A = B = 0;

cin>>N;
//23478
for(int n = 0; n< N; n++)
{
cin.get();
cin>> inputN;
for(input =0; input<inputN; input++){
cin>> weight[input];
}
cin.get();

teamA = teamB = A = B = 0;
aver = returnAver(weight);

for(int cycle=0; cycle < MAX; cycle++){
maxInInput = maxToZero( weight);

if(	teamA + maxInInput == aver ){
teamA += maxInInput;
}else if( teamB + maxInInput == aver ){
teamB += maxInInput;
}else if( teamA < teamB ){
teamA += maxInInput;
}else{
teamB += maxInInput;;
}
}

outA[n] = teamA;
outB[n] = teamB;
}

for(n=0; n<N; n++)
cout<<outA[n]<<" "<<outB[n]<<endl;
}

int maxToZero(int * weight){
int max = 0;
int maxsIndex = 0;
for(int cycle=0; cycle < MAX; cycle++){
if(max < weight[cycle]){
max = weight[cycle];
maxsIndex = cycle;
}
}
weight[ maxsIndex ] = 0;
return max;
}

int returnAver(int * weight){
int sum  =0;
for(int cycle=0; cycle<MAX ; cycle++){
sum += weight[cycle];
}
return ( sum / 2);
}
```