結果

問題 No.564 背の順
コンテスト
ユーザー norioc
提出日時 2017-11-18 12:20:26
言語 D
(dmd 2.112.0)
コンパイル:
dmd -fPIE -m64 -w -wi -O -release -inline -I/opt/dmd/src/druntime/import/ -I/opt/dmd/src/phobos -L-L/opt/dmd/linux/lib64/ -fPIC _filename_
実行:
./Main
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 670 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 652 ms
コンパイル使用メモリ 94,148 KB
実行使用メモリ 7,716 KB
最終ジャッジ日時 2026-03-05 17:29:51
合計ジャッジ時間 1,209 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 9
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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