結果
問題 | No.564 背の順 |
ユーザー | tokizo |
提出日時 | 2018-01-14 16:28:16 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 935 bytes |
コンパイル時間 | 744 ms |
コンパイル使用メモリ | 82,136 KB |
実行使用メモリ | 4,380 KB |
最終ジャッジ日時 | 2023-08-25 17:23:46 |
合計ジャッジ時間 | 1,477 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,380 KB |
testcase_01 | AC | 2 ms
4,376 KB |
testcase_02 | AC | 2 ms
4,376 KB |
testcase_03 | AC | 1 ms
4,376 KB |
testcase_04 | AC | 2 ms
4,380 KB |
testcase_05 | AC | 1 ms
4,380 KB |
testcase_06 | AC | 1 ms
4,380 KB |
testcase_07 | AC | 1 ms
4,380 KB |
testcase_08 | AC | 2 ms
4,380 KB |
testcase_09 | AC | 1 ms
4,376 KB |
testcase_10 | AC | 1 ms
4,380 KB |
testcase_11 | AC | 2 ms
4,376 KB |
コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内: main.cpp:41:38: 警告: ‘idx’ may be used uninitialized [-Wmaybe-uninitialized] 41 | if(idx % 10 == 1) cout << idx << "st" << endl; | ^~~~ main.cpp:33:9: 備考: ‘idx’ はここで定義されています 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; }