ehddnjs198   4년 전

#include<stdio.h>

int main() {  int student[1000][3],overlap=0,temp,sub_overlap[3];  int i,j,get1,sum_score[3];  int sum_3count[3], sum_2count[3];  for (i = 0; i < 3; i++)  {   sum_score[i] = 0;   sum_2count[i] = 0;   sum_3count[i] = 0;  }  scanf("%d", &get1);  for (i = 0; i < get1; i++)  {   scanf("%d %d %d", &student[i][0], &student[i][1], &student[i][2]);  }  for (i = 0; i < get1; i++)  {   if (student[i][0] == 2)   {    sum_2count[0] += 1;   }   if (student[i][1] == 2)   {    sum_2count[1] += 1;   }   if (student[i][2] == 2)   {    sum_2count[2] += 1;   }   if (student[i][0] == 3)   {    sum_3count[0] += 1;   }   if (student[i][1] == 3)   {    sum_3count[1] += 1;   }   if (student[i][2] == 3)   {    sum_3count[2] += 1;   }  }  for (i = 0; i < get1; i++)  {   sum_score[0] += student[i][0];   sum_score[1] += student[i][1];   sum_score[2] += student[i][2];  }  sub_overlap[0] = sum_score[0];  sub_overlap[1] = sum_score[1];  sub_overlap[2] = sum_score[2];  for (i = 0; i < get1; i++)  {   for (j = 0; j < get1; j++)   {    if (i != j)    {     if (sub_overlap[i]>sub_overlap[j])     {      temp = sub_overlap[i];      sub_overlap[i] = sub_overlap[j];      sub_overlap[j] = temp;     }    }   }  }  if (sub_overlap[0] == sub_overlap[1] && sub_overlap[0] > sub_overlap[2])  {   overlap = 2;  }  else if (sub_overlap[0] == sub_overlap[2])  {   overlap = 3;  }  else if (sub_overlap[0] > sub_overlap[1])  {   overlap = 1;  }

 if (overlap == 1)  {   for (i = 0; i < 3; i++)   {    if (sum_score[i] == sub_overlap[0])    {     printf("%d %d\n", i+1, sum_score[i]);    }   }  }  else if (overlap == 3) {   {/* 0 이 제일 클때 1이 제일 클때 2가 제일 클때    0,1이 겹칠때 ,0,2가 겹칠때 1,2가 겹칠때    0이클때 1이클때 0이클때 2가 클때 1이클때 2가클대    0,1이 같을때 0 2가 같을때 1,2가 같을때

   1,2,3겹칠때*/    if (sum_3count[0] > sum_3count[1] && sum_3count[0] > sum_3count[2])    {     printf("%d %d", 1, sub_overlap[0]);    }    else if (sum_3count[1] > sum_3count[0] && sum_3count[1] > sum_3count[2])    {     printf("%d %d", 2, sub_overlap[0]);    }    else if (sum_3count[2] > sum_3count[0] && sum_3count[2] > sum_3count[1])    {     printf("%d %d", 3, sub_overlap[0]);    }    /////////////////////////////////////////////////////////////////////

   if (sum_3count[0] == sum_3count[1] && sum_3count[0] > sum_3count[2])    {     if (sum_2count[0] > sum_2count[1])     {      printf("%d %d", 1, sub_overlap[0]);     }     else if (sum_2count[1] > sum_2count[0])     {      printf("%d %d", 2, sub_overlap[0]);     }     else if (sum_2count[0] == sum_2count[1])     {      printf("%d %d", 0, sub_overlap[0]);     }    }

   else if (sum_3count[0] == sum_3count[2] && sum_3count[0] > sum_3count[1])    {     if (sum_2count[0] > sum_2count[2])     {      printf("%d %d", 1, sub_overlap[0]);     }     else if (sum_2count[2] > sum_2count[0])     {      printf("%d %d", 3, sub_overlap[0]);     }     else if (sum_2count[0] == sum_2count[2])     {      printf("%d %d", 0, sub_overlap[0]);     }    }

   else if (sum_3count[1] == sum_3count[2] && sum_3count[1] > sum_3count[0])    {     if (sum_2count[1] > sum_2count[2])     {      printf("%d %d", 2, sub_overlap[0]);     }     else if (sum_2count[2] > sum_2count[1])     {      printf("%d %d", 3, sub_overlap[0]);     }     else if (sum_2count[1] == sum_2count[2])     {      printf("%d %d", 0, sub_overlap[0]);     }    }    else if (sum_3count[0] == sum_3count[1] == sum_3count[2])    {     if (sum_2count[0] > sum_2count[1] && sum_2count[0] > sum_2count[2])     {      printf("%d %d", 1, sub_overlap[0]);     }     else if (sum_2count[1] > sum_2count[2] && sum_2count[1] > sum_2count[0])     {      printf("%d %d", 2, sub_overlap[0]);     }     else if (sum_2count[2] > sum_2count[1] && sum_2count[2] > sum_2count[0])     {      printf("%d %d", 2, sub_overlap[0]);     }

    if (sum_2count[0] == sum_2count[1] && sum_2count[0] > sum_2count[2])     {      printf("%d %d", 0, sub_overlap[0]);     }     else if (sum_2count[0] == sum_2count[2] && sum_2count[0] > sum_2count[1])     {      printf("%d %d", 0, sub_overlap[0]);     }     else if (sum_2count[1] == sum_2count[2] && sum_2count[1] > sum_2count[0])     {      printf("%d %d", 0, sub_overlap[0]);     }     if (sum_2count[0] == sum_2count[1] == sum_2count[2])     {      printf("%d %d", 0, sub_overlap[0]);     }    }   }

 }  ////////////////////////////////////////////////////////////////////////////  else if (overlap == 2)  {   int a, b;   if (sub_overlap[0] == sum_score[0] && sub_overlap[0] == sum_score[1])   {    a = 0;    b = 1;   }   else if (sub_overlap[0] == sum_score[0] && sub_overlap[0] == sum_score[2])   {    a = 0;    b = 2;   }   else if (sub_overlap[0] == sum_score[1] && sub_overlap[0] == sum_score[2])   {    a = 1;    b = 2;   }   if (sum_3count[a] > sum_3count[b])   {    printf("%d %d", a + 1, sub_overlap[0]);   }   else if (sum_3count[a] < sum_3count[b])   {    printf("%d %d", b + 1, sub_overlap[0]);   }   else if (sum_3count[a] == sum_3count[b])   {    //////////////////////////////////    if (sum_2count[a] > sum_2count[b])    {     printf("%d %d", a + 1, sub_overlap[0]);    }    else if (sum_2count[a] < sum_2count[b])    {     printf("%d %d", b + 1, sub_overlap[0]);    }    else if (sum_2count[a] == sum_2count[b])    {     printf("%d %d", 0, sub_overlap[0]);    }   }

 }  return 0; }

댓글을 작성하려면 로그인해야 합니다.