#include <stdio.h>
#include <string.h>
#include <stdlib.h>

typedef struct study {
    int ko;
    int en;
    int math;
    char name[11];
} Study;

Study person[100001];


//1국어 감소 2. 영어 증가 3.수학 감소 4.이름 사전순
int compare (const void *a,const void *b){
    const Study *A =(const Study *)a;
    const Study *B =(const Study *)b;
    if(A->ko != B->ko) return B->ko - A->ko;

    if(A->en != B->en) return A->en - B->en;

    if(A->math != B->math) return B->math - A->math;

    return strcmp(A->name, B->name);

    
}


int main() {
    int n;
    scanf("%d",&n);
    for(int i=0;i<n; i++) {
        scanf("%s %d %d %d",person[i].name,&person[i].ko,&person[i].en,&person[i].math);
    }
    
    qsort(person,n,sizeof(Study),compare);
    
    for(int i=0; i<n; i++) {
        printf("%s\n",person[i].name);
    }
    return 0;
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: