結果
| 問題 |
No.564 背の順
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-01-22 20:37:30 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 34 ms / 2,000 ms |
| コード長 | 1,025 bytes |
| コンパイル時間 | 963 ms |
| コンパイル使用メモリ | 108,416 KB |
| 実行使用メモリ | 19,200 KB |
| 最終ジャッジ日時 | 2024-09-16 04:18:19 |
| 合計ジャッジ時間 | 1,951 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 9 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
static void Main(string[] args)
{
var line = Console.ReadLine().Split(' ');
var height = int.Parse(line[0]);
var N = int.Parse(line[1]);
var list = new List<int>(N) { height };
for (int i = 0; i < N-1; i++)
list.Add(int.Parse(Console.ReadLine()));
list = list.OrderByDescending(x => x).Distinct().ToList();
string idxStr = (list.IndexOf(height) + 1).ToString();
char od = (idxStr.Length >= 2) ? idxStr[1]: idxStr[0];
switch (od)
{
case '1':
Console.WriteLine("{0}st", idxStr);
break;
case '2':
Console.WriteLine("{0}nd", idxStr);
break;
case '3':
Console.WriteLine("{0}rd", idxStr);
break;
default:
Console.WriteLine("{0}th", idxStr);
break;
}
}
}