結果

問題 No.564 背の順
ユーザー tenkyu9tenkyu9
提出日時 2018-03-06 06:49:10
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,032 bytes
コンパイル時間 717 ms
コンパイル使用メモリ 78,636 KB
実行使用メモリ 4,368 KB
最終ジャッジ日時 2023-10-12 16:28:17
合計ジャッジ時間 1,462 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
using namespace std;
typedef long long int ll;

int main(){

  int h[101], n, H;
  cin >> h[0] >> n;
  H=h[0];
  for(int i=1; i<n; i++){
    cin >> h[i];
  }
  n++;
  sort(h, h+n);
  for(int i=0; i<n; i++){
    if(H==h[i]){
      if((n-i)%10==1 && (n-i)<10){
        cout << 1 << "st" << endl;
        return 0;
      } else if((n-i)%10==2 && (n-i)<10){
        cout << 2 << "nd" << endl;
        return 0;
      } else if((n-i)%10==3 && (n-i)<10){
        cout << 3 << "rd" << endl;
        return 0;
      } else if((n-i)%10==1 && (n-i)>10){
        cout << n-i << "st" << endl;
        return 0;
      } else if((n-i)%10==2 && (n-i)>10){
        cout << n-i << "nd" << endl;
        return 0;
      } else if((n-i)%10==3 && (n-i)>10){
        cout << n-i << "rd" << endl;
        return 0;
      } else {
        cout << n-i << "th" << endl;
      }
    }
  }

  return 0;
}
0