結果

問題 No.564 背の順
ユーザー nanophoto12nanophoto12
提出日時 2017-09-08 22:27:33
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,317 bytes
コンパイル時間 808 ms
コンパイル使用メモリ 97,124 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-07 08:26:51
合計ジャッジ時間 1,455 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <cmath>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <functional>
#include <queue>
#include <iostream>
#include <string.h>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <cstdint>
#include <climits>
#include <unordered_set>
#include <sstream>
#include <stack>

using namespace std;

typedef long long int ll;
typedef pair<ll,ll> pii;
typedef tuple<double,int,int> t3;

using namespace std;

void solve()
{
    int h, n;
    cin >> h >> n;
    vector<int> v;
    v.emplace_back(h);
    for(int i = 2;i <= n;i++)
    {
        int hh;
        cin >> hh;
        v.emplace_back(hh);
    }
    sort(v.begin(), v.end());
    int index = 1;
    for(auto e = v.rbegin();e != v.rend();e++)
    {
        if(*e == h)
        {
            if(index % 10 == 1)
            {
                cout << index << "st" << endl;
                return;
            }
            if(index % 10 == 2)
            {
                cout << index << "nd" << endl;
                return;
            }
            if(index % 10 == 3)
            {
                cout << index << "rd" << endl;
                return;
            }
            cout << index << "th" << endl;
            return;
        }
        index++;
    }
    
}

int main()
{
    solve();
    return 0;
}
0