結果

問題 No.564 背の順
ユーザー nCk_cvnCk_cv
提出日時 2017-12-31 17:44:59
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 884 bytes
コンパイル時間 809 ms
コンパイル使用メモリ 83,580 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-23 12:32:34
合計ジャッジ時間 1,566 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

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

using namespace std;

void solve();

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
}

void solve() {
    int H,n;
    cin >> H >> n;
    int h[n];
    for(int i = 0; i < n-1; i++) {
        cin >> h[i];
    }
    vector<pair<int,int> > v;
    v.push_back(make_pair(H,0));
    for(int i = 0; i < n-1; i++) {
        v.push_back(make_pair(h[i],1));
    }
    sort(v.begin(), v.end());
    for(int i = 0; i < n; i++) {
        if(v.at(i).second == 0) {
            int tmp = n - i;
            cout << tmp;
            if(tmp % 10 == 1) cout << "st";
            else if(tmp % 10 == 2) cout << "nd";
            else if(tmp % 10 == 3) cout << "rd";
            else cout << "th";
            cout << endl;
            break;
        }
    }

    
}
0