結果

問題 No.564 背の順
ユーザー ふうふう
提出日時 2017-09-08 22:31:36
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 901 bytes
コンパイル時間 662 ms
コンパイル使用メモリ 88,760 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-07 08:29:16
合計ジャッジ時間 1,361 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,376 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 2 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:42:10: warning: ‘res’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  cout << res;
          ^~~

ソースコード

diff #

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <queue>
#include <functional>
#include <map>


using namespace std;

#define MOD 1000000007
#define INF 2147483647
#define ll long long


int main()
{
	int res;
	int h, n;
	cin >> h >> n;
	
	vector<pair<int, int>> hi;
	
	hi.push_back(pair<int, int>(h, 0));
	for (int i = 0; i < n-1; i++) {
		int a;
		cin >> a;
		hi.push_back(pair<int, int>(a, 1));
	}
	sort(hi.begin(), hi.end(), greater<pair<int, int>>());
	for (int i = 0; i < n; i++) {
		if (hi[i].second == 0) {
			res = i + 1;
			break;
		}
	}
	cout << res;
	if (res % 10 == 1) {
		cout << "st" << endl;
	}
	else if (res % 10 == 2) {
		cout << "nd" << endl;
	}
	else if (res % 10 == 3) {
		cout << "rd" << endl;
	}
	else {
		cout << "th" << endl;
	}


	return (0);
}
0