結果
| 問題 |
No.564 背の順
|
| コンテスト | |
| ユーザー |
ふう
|
| 提出日時 | 2017-09-08 22:30:36 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 900 bytes |
| コンパイル時間 | 1,147 ms |
| コンパイル使用メモリ | 118,120 KB |
| 最終ジャッジ日時 | 2025-01-05 02:46:04 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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;
| ^~~
ソースコード
#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;
}
if (res % 10 == 2) {
cout << "nd" << endl;
}
if (res % 10 == 3) {
cout << "rd" << endl;
}
if (res >= 4) {
cout << "th" << endl;
}
return (0);
}
ふう