ACM준비/acmicpc

Contest Scoreboard

조규현15 2015. 1. 8. 10:33
반응형
예제 결과 : 성공
채점 결과 : Wrong Answer
이유 : 주석? 출력포맷?
         내용상으로는 이유를 찾기 힘들다..

 


//////////////////////////////
// #15 Contest Scoreboard //
// pc ID : 110207 //
//////////////////////////////

#include <stdio.h>

int main()
{

    int _n;

    scanf("%d", &_n); // Case of Num
    puts("");         // inline
    while (_n--)
    {
        int N_team, N_problem, N_time;
        char C_L;
        int Array_Team[100][3] = {
            0,
        }; // team , soulution, time
        int Array_Time_Minus[100][10] = {
            0,
        };
        int index_Team = 0;
        int i, index_BiggestTeam;
        int temp; // swap temp

        // input part
        while (scanf("%d %d %d %c", &N_team, &N_problem, &N_time, &C_L) != -1)
        { // end of Ctrl + Z
            int B_plag = 1;

            for (i = 0; i < index_Team; i++)
                if (Array_Team[i][0] == N_team)
                {
                    switch (C_L)
                    {
                    case 'C':
                        Array_Team[i][1]++;                                          //+1 soulution
                        Array_Team[i][2] += N_time + Array_Time_Minus[i][N_problem]; // add time and panelty
                        break;
                    case 'I':
                        Array_Time_Minus[i][N_problem] += 20; // add it's N_problem add 20 panelty
                        break;
                    case 'R':
                    case 'U':
                        // no action
                        break;
                    default:
                        // error input
                        break;
                    }
                    B_plag = 0;
                }

            if (B_plag)
            { // plut index size
                Array_Team[index_Team][0] = N_team;
                switch (C_L)
                {
                case 'C':
                    Array_Team[index_Team][1]++;                                                  //+1 soulution
                    Array_Team[index_Team][2] = N_time + Array_Time_Minus[index_Team][N_problem]; // add time and panelty
                    break;
                case 'I':
                    Array_Time_Minus[index_Team][N_problem] += 20; // add it's N_problem add 20 panelty
                    break;
                case 'R':
                case 'U':
                    // no action
                    break;
                default:
                    // error input
                    break;
                }
                index_Team++;
            }
        }

        while (1)
        {
            index_BiggestTeam = 0;
            // print part
            for (i = 0; i < index_Team; i++)
            {
                if (Array_Team[i][1] > Array_Team[index_BiggestTeam][1]) // compare N_soulution
                    index_BiggestTeam = i;
                else if (Array_Team[i][1] == Array_Team[index_BiggestTeam][1]) // if same N_solutuon
                    if (Array_Team[i][2] < Array_Team[index_BiggestTeam][2])   // comapre N_time
                        index_BiggestTeam = i;
            }
            // sort.. index_Team and index_BiggestTeam
            index_Team--;
            if (index_Team < 0) // out of while(1)
                break;
            temp = Array_Team[index_BiggestTeam][0]; // N_team
            Array_Team[index_BiggestTeam][0] = Array_Team[index_Team][0];
            Array_Team[index_Team][0] = temp;
            temp = Array_Team[index_BiggestTeam][1]; // N_solution
            Array_Team[index_BiggestTeam][1] = Array_Team[index_Team][1];
            Array_Team[index_Team][1] = temp;
            temp = Array_Team[index_BiggestTeam][2]; // N_time
            Array_Team[index_BiggestTeam][2] = Array_Team[index_Team][2];
            Array_Team[index_Team][2] = temp;

            // biggestTeam
            printf("%d %d %d\n", Array_Team[index_Team][0], Array_Team[index_Team][1], Array_Team[index_Team][2]);
        }
        if (_n > 0)
            puts(""); // inline
    }

    return 0;
}
반응형

'ACM준비 > acmicpc' 카테고리의 다른 글

ACM Craft  (0) 2015.10.30
어린왕자  (0) 2015.07.07
터렛  (0) 2015.07.07
Bee Maja  (0) 2015.01.08
Where's Waldorf?  (0) 2015.01.08