Submission #65533869


Source Code Expand

Copy
#include <stdio.h>
#include <stdlib.h>
/* */
int cmp(const void* x, const void* y) {
int a = *(const int*)x, b = *(const int*)y;
return a > b ? -1 : a < b;
}
int main(void) {
int N, *A;
int i;
if (scanf("%d", &N) != 1) return 1;
A = malloc(sizeof(*A) * N);
if (A == NULL) return 2;
for (i = 0; i < N; i++) {
if (scanf("%d", &A[i]) != 1) return 1;
}
qsort(A, N, sizeof(*A), cmp);
printf("%d\n", A[3] - A[4]);
free(A);
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#include <stdio.h>
#include <stdlib.h>

/* 降順 */
int cmp(const void* x, const void* y) {
	int a = *(const int*)x, b = *(const int*)y;
	return a > b ? -1 : a < b;
}

int main(void) {
	int N, *A;
	int i;
	if (scanf("%d", &N) != 1) return 1;
	A = malloc(sizeof(*A) * N);
	if (A == NULL) return 2;
	for (i = 0; i < N; i++) {
		if (scanf("%d", &A[i]) != 1) return 1;
	}
	qsort(A, N, sizeof(*A), cmp);
	printf("%d\n", A[3] - A[4]);
	free(A);
	return 0;
}

Submission Info

Submission Time
Task A - An Easy Ranking Problem
User mikecat
Language C (gcc 12.2.0)
Score 100
Code Size 476 Byte
Status AC
Exec Time 0 ms
Memory 1756 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 100 / 100
Status
AC × 3
AC × 13
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_test_00.txt, 01_test_01.txt, 01_test_02.txt, 01_test_03.txt, 01_test_04.txt, 01_test_05.txt, 01_test_06.txt, 01_test_07.txt, 01_test_08.txt, 01_test_09.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 0 ms 1728 KB
00_sample_01.txt AC 0 ms 1748 KB
00_sample_02.txt AC 0 ms 1724 KB
01_test_00.txt AC 0 ms 1588 KB
01_test_01.txt AC 0 ms 1744 KB
01_test_02.txt AC 0 ms 1656 KB
01_test_03.txt AC 0 ms 1756 KB
01_test_04.txt AC 0 ms 1704 KB
01_test_05.txt AC 0 ms 1712 KB
01_test_06.txt AC 0 ms 1596 KB
01_test_07.txt AC 0 ms 1632 KB
01_test_08.txt AC 0 ms 1636 KB
01_test_09.txt AC 0 ms 1712 KB


2025-05-05 (Mon)
23:39:45 +09:00