結果

問題 No.564 背の順
ユーザー vtr_codervtr_coder
提出日時 2017-09-08 22:36:37
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 886 bytes
コンパイル時間 1,529 ms
コンパイル使用メモリ 169,220 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-07 08:30:48
合計ジャッジ時間 2,211 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))

#define MOD 1000000007
#define INF 1000000000

int H, N;
vector<int> height;

int main()
{
    cin >> H >> N;
    height.push_back(H);
    REP(i, N-1) {
        int tmp;
        cin >> tmp;
        height.push_back(tmp);
    }
    sort(height.begin(), height.end(), greater<int>());
    int num;
    for(num = 1; num <= N; ++num) {
        //printf("height[%d]: %d\n", num-1, height[num-1]);
        if(height[num-1] == H) { break; }
    }
    printf("%d", num);
    if(num % 10 == 1) { printf("st\n"); }
    else if(num % 10 == 2) { printf("nd\n"); }
    else if(num  % 10 == 3) { printf("rd\n"); }
    else { printf("th\n"); }
    return 0;
}
0