Submission #64711815
Source Code Expand
Copy
#include <stdio.h>#include <stdlib.h>struct hito_s {int id, score;};/* 得点の降順 */int cmp(const void* x, const void* y) {struct hito_s a = *(const struct hito_s*)x, b = *(const struct hito_s*)y;return a.score > b.score ? -1 : a.score < b.score;}int main(void) {int N;struct hito_s* hito;int* ans;int i;int zyuni = 1, zyuni_start = 0;if (scanf("%d", &N) != 1) return 1;hito = malloc(sizeof(*hito) * N);
#include <stdio.h>
#include <stdlib.h>
struct hito_s {
int id, score;
};
/* 得点の降順 */
int cmp(const void* x, const void* y) {
struct hito_s a = *(const struct hito_s*)x, b = *(const struct hito_s*)y;
return a.score > b.score ? -1 : a.score < b.score;
}
int main(void) {
int N;
struct hito_s* hito;
int* ans;
int i;
int zyuni = 1, zyuni_start = 0;
if (scanf("%d", &N) != 1) return 1;
hito = malloc(sizeof(*hito) * N);
ans = malloc(sizeof(*ans) * N);
if (hito == NULL || ans == NULL) return 2;
for (i = 0; i < N; i++) {
if (scanf("%d", &hito[i].score) != 1) return 1;
hito[i].id = i;
}
qsort(hito, N, sizeof(*hito), cmp);
for (i = 1; i <= N; i++) {
if (i >= N || hito[i].score != hito[i - 1].score) {
int k = i - zyuni_start;
int j;
for (j = zyuni_start; j < i; j++) {
ans[hito[j].id] = zyuni;
}
zyuni += k;
zyuni_start = i;
}
}
for (i = 0; i < N; i++) {
printf("%d\n", ans[i]);
}
free(hito);
free(ans);
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | B - Ranking with Ties |
| User | mikecat |
| Language | C (gcc 12.2.0) |
| Score | 200 |
| Code Size | 1026 Byte |
| Status | AC |
| Exec Time | 1 ms |
| Memory | 1756 KB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 200 / 200 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt |
| All | 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 02_random2_00.txt, 02_random2_01.txt, 02_random2_02.txt, 02_random2_03.txt, 02_random2_04.txt, 02_random2_05.txt, 02_random2_06.txt, 02_random2_07.txt, 02_random2_08.txt, 03_sorted_00.txt, 03_sorted_01.txt, 04_handmade_00.txt, 04_handmade_01.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 00_sample_00.txt | AC | 1 ms | 1636 KB |
| 00_sample_01.txt | AC | 1 ms | 1604 KB |
| 00_sample_02.txt | AC | 1 ms | 1628 KB |
| 00_sample_03.txt | AC | 0 ms | 1720 KB |
| 01_random_00.txt | AC | 1 ms | 1752 KB |
| 01_random_01.txt | AC | 1 ms | 1728 KB |
| 01_random_02.txt | AC | 1 ms | 1720 KB |
| 01_random_03.txt | AC | 1 ms | 1732 KB |
| 02_random2_00.txt | AC | 1 ms | 1736 KB |
| 02_random2_01.txt | AC | 1 ms | 1636 KB |
| 02_random2_02.txt | AC | 0 ms | 1728 KB |
| 02_random2_03.txt | AC | 1 ms | 1744 KB |
| 02_random2_04.txt | AC | 1 ms | 1636 KB |
| 02_random2_05.txt | AC | 1 ms | 1708 KB |
| 02_random2_06.txt | AC | 0 ms | 1724 KB |
| 02_random2_07.txt | AC | 1 ms | 1656 KB |
| 02_random2_08.txt | AC | 0 ms | 1756 KB |
| 03_sorted_00.txt | AC | 1 ms | 1624 KB |
| 03_sorted_01.txt | AC | 1 ms | 1636 KB |
| 04_handmade_00.txt | AC | 1 ms | 1596 KB |
| 04_handmade_01.txt | AC | 1 ms | 1656 KB |