結果

問題 No.564 背の順
ユーザー Mcpu3Mcpu3
提出日時 2018-04-15 19:44:20
言語 C
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 889 bytes
コンパイル時間 151 ms
コンパイル使用メモリ 30,140 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-09 06:56:57
合計ジャッジ時間 958 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 0 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 0 ms
4,376 KB
testcase_03 WA -
testcase_04 AC 0 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 0 ms
4,380 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main(void)
{
	int n[2];
	char str[32], *ch;
	fgets(str, sizeof(str), stdin);
	ch = strtok(str, " \n");
	for (int i = 0; i < 2; i++) {
		if (ch == NULL) break;
		else n[i] = atoi(ch);
		ch = strtok(NULL, " \n");
	}
	int *h = malloc(sizeof(int)*(n[1] - 1));
	for (int i = 0; i < n[1] - 1; i++) scanf("%d", &h[i]);
	int tmp;
	for (int i = 0; i < n[1] - 2; i++) {
		for (int j = 0; j < n[1] - 2; j++) {
			if (h[j] < h[j + 1]) {
				tmp = h[j];
				h[j] = h[j + 1];
				h[j + 1] = tmp;
			}
		}
	}
	int ans = 1;
	for (int i = 0; i < n[1] - 1; i++) {
		if (n[0] > h[i]) break;
		ans++;
	}
	switch (ans) {
	case 1:
		printf("1st");
		break;
	case 2:
		printf("2nd");
		break;
	case 3:
		printf("3rd");
		break;
	default:
		printf("%dth", ans);
		break;
	}
	printf("\n");
	return 0;
}
0