結果

問題 No.564 背の順
ユーザー michonz4michonz4
提出日時 2019-09-20 10:03:21
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 509 bytes
コンパイル時間 920 ms
コンパイル使用メモリ 66,552 KB
実行使用メモリ 4,352 KB
最終ジャッジ日時 2023-10-11 21:19:47
合計ジャッジ時間 1,358 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

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

using namespace std;

int main() {
  int h, n;
  cin >> h >> n;
  vector<int> v(n);
  v[0]=h;

  for (int i=1; i<n; i++) {
    cin >> v[i];
  }

  sort(v.begin(), v.end(), greater<int>());

  for (int i=0; i<n; i++) {
    if (v[i]==h) {
      if (i+1==1) cout << "1st" << endl;
      else if (i+1==2) cout << "2nd" << endl;
      else if (i+1==3) cout << "3rd" << endl;
      else cout << i+1 << "th" << endl;
      return 0;
    }
  }
  return 0;
}
0