結果

問題 No.564 背の順
ユーザー 37zigen37zigen
提出日時 2019-08-12 18:08:46
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 649 bytes
コンパイル時間 696 ms
コンパイル使用メモリ 74,320 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-17 07:16:31
合計ジャッジ時間 1,438 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

int main(){
  int H, N;
  std::cin >> H >> N;
  std::vector<int> a(N+1);
  a[0] = H;
  for (int i = 0; i < N - 1; ++i) {
    int b;
    std::cin >> b;
    a[i + 1] = b;
  }
  std::sort(a.begin(), a.end(), std::greater<int>());
  for (int i = 0; i < N; ++i) {
    if (a[i] == H) {
      std::cout << (i + 1);
      if ((i + 1) % 10 == 1) {
	std::cout << "st";
      } else if ((i + 1) % 10 == 2) {
	std::cout << "nd";
      } else if ((i + 1) % 10 ==3) {
	std::cout << "rd";
      } else {
	std::cout << "th";
      }
      std::cout << std::endl;
    }
  }
  return 0;
}
0