結果
| 問題 | No.564 背の順 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-09-09 17:32:54 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 710 bytes |
| コンパイル時間 | 637 ms |
| コンパイル使用メモリ | 64,412 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-07 09:53:23 |
| 合計ジャッジ時間 | 1,218 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 6 WA * 3 |
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
// input
int H, N;
cin >> H >> N;
vector<int> h(N);
for (int i = 0; i < N; ++i) {
cin >> h[i];
}
// solve & output
sort(h.begin(), h.end());
if (h[N - 1] < H) {
cout << "1st" << endl;
return 0;
} else if (h[N - 2] < H) {
cout << "2nd" << endl;
return 0;
} else if (h[N - 3] < H) {
cout << "3rd" << endl;
return 0;
} else {
for (int i = N - 4; i >= 0; --i) {
if (h[i] < H) {
cout << N - i << "th" << endl;
break;
}
}
}
return 0;
}