結果

問題 No.564 背の順
ユーザー tapiokatapioka
提出日時 2017-09-09 17:30:54
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 710 bytes
コンパイル時間 579 ms
コンパイル使用メモリ 64,924 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-25 00:28:31
合計ジャッジ時間 1,096 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#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 << i + 4 << "th" << endl;
                break;
            }
        }
    }

    return 0;
}
0