結果
問題 | No.564 背の順 |
ユーザー |
![]() |
提出日時 | 2023-06-13 11:23:52 |
言語 | C (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 1 ms / 2,000 ms |
コード長 | 818 bytes |
コンパイル時間 | 1,116 ms |
コンパイル使用メモリ | 29,696 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-12 23:43:05 |
合計ジャッジ時間 | 1,031 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 9 |
ソースコード
#include <stdio.h>#include <stdlib.h>int cmp(const void* n1, const void* n2){if (*(int*)n1 > *(int*)n2) {return -1;}else if (*(int*)n1 < *(int*)n2) {return 1;}return 0;}int main(){int h1, N, ans = 0;int* H;if (scanf("%d %d", &h1, &N) != 2) {return -1;}H = (int*)malloc(sizeof(int) * N);if (H == NULL) {return -1;}*(H + 0) = h1;for (int i = 1; i < N; i++) {if (scanf("%d", &*(H + i)) != 1) {return -1;}}qsort(H, N, sizeof(int), cmp);for (int i = 0; i < N; i++) {if (*(H + i) == h1) {ans = i + 1;break;}}switch (ans % 10){case 1:printf("%dst", ans);break;case 2:printf("%dnd", ans);break;case 3:printf("%drd", ans);break;default:printf("%dth", ans);break;}free(H);H = NULL;return 0;}