結果
| 問題 | No.564 背の順 |
| コンテスト | |
| ユーザー |
Ronlynes
|
| 提出日時 | 2017-09-08 22:28:18 |
| 言語 | C++11 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 2,000 ms |
| コード長 | 783 bytes |
| 記録 | |
| コンパイル時間 | 429 ms |
| コンパイル使用メモリ | 78,692 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-05-07 20:31:30 |
| 合計ジャッジ時間 | 1,176 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 9 |
コンパイルメッセージ
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/string:56,
from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/locale_classes.h:42,
from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/ios_base.h:43,
from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/ios:46,
from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/ostream.h:43,
from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/ostream:42,
from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/iostream:43,
from main.cpp:1:
In function 'std::string std::__cxx11::to_string(int)',
inlined from 'int main()' at main.cpp:26:29:
/home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/basic_string.h:4536:20: warning: 'ans' may be used uninitialized [-Wmaybe-uninitialized]
4536 | const unsigned __uval = __neg ? (unsigned)~__val + 1u : __val;
| ^~~~~~
main.cpp: In function 'int main()':
main.cpp:19:9: note: 'ans' was declared here
19 | int ans;
| ^~~
ソースコード
#include <iostream>
#include <algorithm>
using namespace std;
bool comp(const int& e1, const int& e2){
if(e1 > e2){
return true;
}else{
return false;
}
}
int main(void){
int h[103], n;
cin >> h[0] >> n;
int nama = h[0];
for(int i=1; i<n; i++){
cin >> h[i];
}
sort(h, h+n, comp);
int ans;
for(int i=0; i<n; i++){
if(h[i] == nama){
ans = i+1;
break;
}
}
string s = to_string(ans);
if(s[s.length()-1] == '1'){
cout << ans << "st" << endl;
}else if(s[s.length()-1] == '2'){
cout << ans << "nd" << endl;
}else if(s[s.length()-1] == '3'){
cout << ans << "rd" << endl;
}else{
cout << ans << "th" << endl;
}
return 0;
}
Ronlynes