結果
| 問題 |
No.564 背の順
|
| コンテスト | |
| ユーザー |
tokizo
|
| 提出日時 | 2018-01-14 16:28:16 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 935 bytes |
| コンパイル時間 | 836 ms |
| コンパイル使用メモリ | 82,992 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-24 02:50:32 |
| 合計ジャッジ時間 | 1,478 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 9 |
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:41:38: warning: 'idx' may be used uninitialized [-Wmaybe-uninitialized]
41 | if(idx % 10 == 1) cout << idx << "st" << endl;
| ^~~~
main.cpp:33:9: note: 'idx' was declared here
33 | int idx;
| ^~~
ソースコード
#include <iostream>
#include <math.h>
#include <algorithm>
#include <functional>
#include <vector>
#include <typeinfo>
#include <climits>
#include <ctype.h>
#include <string>
#include <stdio.h>
using namespace std;
#define INIT cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i, a, n) for (int i = a; i < n; i++)
#define REP(i, n) for(int i = 0; i < n; i++)
int main()
{
INIT;
int h, n;
vector<int> v;
cin >> h >> n;
v.push_back(h);
int tmp;
REP(i, n - 1){
cin >> tmp;
v.push_back(tmp);
}
sort(v.begin(), v.end(), greater<int>());
int idx;
REP(i, v.size()){
if(h == v[i]){
idx = i + 1;
break;
}
}
if(idx % 10 == 1) cout << idx << "st" << endl;
else if(idx % 10 == 2) cout << idx << "nd" << endl;
else if(idx % 10 == 3) cout << idx << "rd" << endl;
else cout << idx << "th" << endl;
return 0;
}
tokizo