#!/usr/local/bin/tcc -run #include #include #include int main(void){ // 自分の得意な言語で // Let's チャレンジ!! int numOfCandidates; int numOfPeople; int numOfTalks; char* tmp; char str[1000]; int i,j; int whoTalks; int candidateSupporters[150] = {0};//配列番号0は誰も支持していない人 int bestCandidatesList[150] = {0}; int maxOfCandidateSupporters = 0; int XthBestCandidates = 1; fgets(str, sizeof(str), stdin); tmp = strtok(str," "); numOfCandidates= atoi(tmp); tmp = strtok(NULL," "); numOfPeople= atoi(tmp); tmp = strtok(NULL," "); numOfTalks= atoi(tmp); candidateSupporters[0] = numOfPeople;//最初は全員支持なし for(i = 0; i < numOfTalks; i++){ scanf("%d", &whoTalks); //printf("%d talked!\n", whoTalks); for(j = 0; j <= numOfCandidates; j++){ if((candidateSupporters[j] != 0) && (j != whoTalks)){ candidateSupporters[whoTalks]++; //printf("Candidate%d's supporters are %d\n",whoTalks, candidateSupporters[whoTalks]); candidateSupporters[j]--; //printf("Candidate%d lost supporters to %d\n", j, candidateSupporters[j]); } } } fprintf( stderr, "Check\n" ); for(i = 1; i <= numOfCandidates; i++){ if(maxOfCandidateSupporters < candidateSupporters[i]) maxOfCandidateSupporters = candidateSupporters[i]; } //printf("maxOfCandidateSupporters is %d\n", maxOfCandidateSupporters); for(i = 1; i <= numOfCandidates; i++){ if(maxOfCandidateSupporters == candidateSupporters[i]){ bestCandidatesList[XthBestCandidates] = i; //printf("%dth best candidate is %d\n", XthBestCandidates, i); XthBestCandidates++; } } fprintf( stderr, "Check\n" ); for(i = 1; i < XthBestCandidates; i++){ printf("%d\n", bestCandidatesList[i]); } return 0; }