結果
問題 | No.564 背の順 |
ユーザー |
![]() |
提出日時 | 2017-09-08 22:31:36 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 901 bytes |
コンパイル時間 | 940 ms |
コンパイル使用メモリ | 89,340 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-07 12:08:12 |
合計ジャッジ時間 | 1,547 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 9 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:42:17: warning: ‘res’ may be used uninitialized in this function [-Wmaybe-uninitialized] 42 | cout << 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 longint 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);}