結果
| 問題 |
No.564 背の順
|
| コンテスト | |
| ユーザー |
sasa
|
| 提出日時 | 2025-03-14 16:34:29 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 645 bytes |
| コンパイル時間 | 439 ms |
| コンパイル使用メモリ | 28,288 KB |
| 実行使用メモリ | 7,324 KB |
| 最終ジャッジ日時 | 2025-03-14 16:34:31 |
| 合計ジャッジ時間 | 1,218 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 WA * 2 |
| other | AC * 1 WA * 8 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:5:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
5 | scanf("%d%d",&height,&val);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~
main.cpp:9:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
9 | scanf("%d",&student[i]);
| ~~~~~^~~~~~~~~~~~~~~~~~
ソースコード
#include <stdio.h>
int main(){
int height,val;
scanf("%d%d",&height,&val);
int student[val];
for(int i = 0;i < val - 1;i ++){
scanf("%d",&student[i]);
}
// ソート(降順)
for(int i = 0;i < val - 1;i ++){
for(int j = 0;j < val - 1;j ++){
if(student[i] > student[j]){
int tmp = student[i];
student[i] = student[j];
student[j] = tmp;
}
}
}
int rank = 0;
for(int i = 0;i < val - 1;i ++){
if(student[i] < height){
rank = i + 1;
}
}
if(rank == 1){
printf("%dst",rank);
}else if(rank == 2){
printf("%dnd",rank);
}else if(rank == 3){
printf("%drd",rank);
}else{
printf("%dth",rank);
}
}
sasa