結果

問題 No.564 背の順
ユーザー norioc
提出日時 2017-11-18 12:20:26
言語 D
(dmd 2.109.1)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 670 bytes
コンパイル時間 890 ms
コンパイル使用メモリ 109,300 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-12 22:35:05
合計ジャッジ時間 1,454 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

int readint() {
    return readln.chomp.to!int;
}

int[] readints() {
    return readln.split.map!(to!int).array;
}

void main() {
    auto hn = readints;
    int h = hn[0], n = hn[1];
    auto xs = [h];
    for (int i = 0; i < n - 1; i++) {
        xs ~= readint;
    }

    xs.sort().reverse();
    auto p = xs.countUntil(h);
    write(p + 1);
    switch ((p + 1) % 10) {
    case 1: writeln("st"); break;
    case 2: writeln("nd"); break;
    case 3: writeln("rd"); break;
    default: writeln("th"); break;
    }
}
0