結果

問題 No.564 背の順
ユーザー ふう
提出日時 2017-09-08 22:27:55
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 885 bytes
コンパイル時間 1,372 ms
コンパイル使用メモリ 118,716 KB
最終ジャッジ日時 2025-01-05 02:45:41
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 6 WA * 3
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:42:17: warning: ‘res’ may be used uninitialized [-Wmaybe-uninitialized]
   42 |         cout << res;
      |                 ^~~
main.cpp:23:13: note: ‘res’ was declared here
   23 |         int 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 == 1) {
		cout << "st" << endl;
	}
	if (res == 2) {
		cout << "nd" << endl;
	}
	if (res == 3) {
		cout << "rd" << endl;
	}
	if (res >= 4) {
		cout << "th" << endl;
	}


	return (0);
}
0