結果
問題 |
No.564 背の順
|
ユーザー |
![]() |
提出日時 | 2017-09-08 22:48:23 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 645 bytes |
コンパイル時間 | 479 ms |
コンパイル使用メモリ | 49,608 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-07 05:48:15 |
合計ジャッジ時間 | 1,046 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 6 WA * 3 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:11:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 11 | scanf("%d%d", &H, &N); | ~~~~~^~~~~~~~~~~~~~~~ main.cpp:15:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 15 | scanf("%d", &hi); | ~~~~~^~~~~~~~~~~
ソースコード
#include <algorithm> #include <cstdio> #include <functional> #include <vector> using namespace std; int main() { vector<int> heights; int H, N; scanf("%d%d", &H, &N); heights.push_back(H); for (int i = 1; i < N; i++) { int hi; scanf("%d", &hi); heights.push_back(hi); } sort(heights.begin(), heights.end(), greater<int>()); int rank = 0; for (int i = 0; i < N; i++) { if (heights[i] == H) { rank = i + 1; break; } } if (rank == 1) printf("%dst", rank); else if (rank == 2) printf("%dnd", rank); else if (rank == 3) printf("%drd", rank); else printf("%dth", rank); }