結果

問題 No.447 ゆきこーだーの雨と雪 (2)
ユーザー くれちーくれちー
提出日時 2016-11-19 19:18:30
言語 C90
(gcc 11.4.0)
結果
AC  
実行時間 66 ms / 2,000 ms
コード長 3,372 bytes
コンパイル時間 246 ms
コンパイル使用メモリ 23,808 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-05 10:09:57
合計ジャッジ時間 2,427 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 5 ms
5,376 KB
testcase_04 AC 5 ms
5,376 KB
testcase_05 AC 45 ms
5,376 KB
testcase_06 AC 44 ms
5,376 KB
testcase_07 AC 19 ms
5,376 KB
testcase_08 AC 21 ms
5,376 KB
testcase_09 AC 55 ms
5,376 KB
testcase_10 AC 3 ms
5,376 KB
testcase_11 AC 7 ms
5,376 KB
testcase_12 AC 11 ms
5,376 KB
testcase_13 AC 49 ms
5,376 KB
testcase_14 AC 66 ms
5,376 KB
testcase_15 AC 8 ms
5,376 KB
testcase_16 AC 4 ms
5,376 KB
testcase_17 AC 6 ms
5,376 KB
testcase_18 AC 3 ms
5,376 KB
testcase_19 AC 51 ms
5,376 KB
testcase_20 AC 66 ms
5,376 KB
testcase_21 AC 8 ms
5,376 KB
testcase_22 AC 8 ms
5,376 KB
testcase_23 AC 12 ms
5,376 KB
testcase_24 AC 36 ms
5,376 KB
testcase_25 AC 51 ms
5,376 KB
testcase_26 AC 20 ms
5,376 KB
testcase_27 AC 17 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:95:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   95 |         scanf("%d", &n);
      |         ^~~~~~~~~~~~~~~
main.c:101:17: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
  101 |                 scanf("%d", &l);
      |                 ^~~~~~~~~~~~~~~
main.c:106:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
  106 |         scanf("%d", &t);
      |         ^~~~~~~~~~~~~~~
main.c:113:17: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
  113 |                 scanf("%s %c", name[i], &p[i]);
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

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

typedef struct {
	int Level;
	int Solve;
} Problem;

Problem *Problem_New(int level) {
	Problem *p;
	p = (Problem *)malloc(sizeof(Problem));
	p->Level = level;
	p->Solve = 0;
	return p;
}

int Problem_GetId(char name) {
	return name - 'A';
}

typedef struct {
	char *Name;
	char ProblemName;
} Submit;

Submit *Submit_New(char *name, char problemName) {
	Submit *s;
	s = (Submit *)malloc(sizeof(Submit));
	s->Name = name;
	s->ProblemName = problemName;
	return s;
}

typedef struct {
	char *Name;
	int Score[26];
	int ScoreSum;
	int LastSubmit;
} Participant;

Participant *Participant_New_1(char *name) {
	Participant *p;
	p = (Participant *)malloc(sizeof(Participant));
	p->Name = name;
	return p;
}

Participant *Participant_New_2(char *name, int problemNum, int lastSubmit) {
	Participant *p;
	p = (Participant *)malloc(sizeof(Participant));
	p->Name = name;
	int i;
	for (i = 0; i < problemNum; i++) p->Score[i] = 0;
	p->ScoreSum = 0;
	p->LastSubmit = lastSubmit;
	return p;
}

int Participant_Equals(Participant *p1, Participant *p2) {
	return strcmp(p1->Name, p2->Name) == 0 ? 1 : 0;
}

int Participant_CompareTo(const void *p1, const void *p2) {
	if (((Participant *)p1)->ScoreSum == ((Participant *)p2)->ScoreSum)
		return ((Participant *)p1)->LastSubmit - ((Participant *)p2)->LastSubmit;
	else
		return ((Participant *)p2)->ScoreSum - ((Participant *)p1)->ScoreSum;
}

void Participant_Solve(Participant *p, int no, int level, int rank) {
	p->Score[no] = 50 * level + (500 * level / (8 + 2 * rank));
	p->ScoreSum += p->Score[no];
}

int Participant_List_Contains(Participant *p1, int size, Participant *p2) {
	int i;
	for (i = 0; i < size; i++) {
		if (Participant_Equals(&p1[i], p2)) return 1;
	}
	return 0;
}

int Participant_List_IndexOf(Participant *p1, int size, Participant *p2) {
	int i;
	for (i = 0; i < size; i++) {
		if (Participant_Equals(&p1[i], p2)) return i;
	}
	return -1;
}


int main() {
	int n;
	scanf("%d", &n);
	Problem problemList[26];

	int i, j;
	for (i = 0; i < n; i++) {
		int l;
		scanf("%d", &l);
		problemList[i] = *Problem_New(l);
	}
	
	int t;
	scanf("%d", &t);
	Submit submitList[4000];
	int cntParticipant = 0;
	Participant participantList[4000];

	for (i = 0; i < t; i++) {
		char name[4000][17], p[4000];
		scanf("%s %c", name[i], &p[i]);
		submitList[i] = *Submit_New(name[i], p[i]);

		if (!Participant_List_Contains(participantList, cntParticipant, 
			Participant_New_1(submitList[i].Name))) {
			participantList[cntParticipant] = *Participant_New_2(name[i], n, i);
			cntParticipant++;
		}

		int tmpProblemNo = 
			Problem_GetId(submitList[i].ProblemName);
		int tmpParticipantNo = 
			Participant_List_IndexOf(participantList, cntParticipant, 
				Participant_New_1(submitList[i].Name));

		problemList[tmpProblemNo].Solve++;
		Participant_Solve(
			&participantList[tmpParticipantNo], 
			tmpProblemNo, 
			problemList[tmpProblemNo].Level, 
			problemList[tmpProblemNo].Solve
		);
		participantList[tmpParticipantNo].LastSubmit = i;
	}

	qsort(participantList, cntParticipant, 
		sizeof(Participant), Participant_CompareTo);

	for (i = 0; i < cntParticipant; i++) {
		printf("%d %s ", i + 1, participantList[i].Name);
		for (j = 0; j < n; j++) {
			printf("%d ", participantList[i].Score[j]);
		}
		printf("%d\n", participantList[i].ScoreSum);
	}

	return 0;
}
0