結果
| 問題 |
No.1046 Fruits Rush
|
| コンテスト | |
| ユーザー |
toto
|
| 提出日時 | 2025-04-01 14:36:14 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 474 bytes |
| コンパイル時間 | 538 ms |
| コンパイル使用メモリ | 28,288 KB |
| 実行使用メモリ | 7,844 KB |
| 最終ジャッジ日時 | 2025-04-01 14:36:16 |
| 合計ジャッジ時間 | 1,118 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 WA * 2 |
| other | AC * 4 WA * 10 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:5:9: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
5 | scanf("%d%d",&val,&quantity);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
main.cpp:9:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
9 | scanf("%d",&fresh[i]);
| ~~~~~^~~~~~~~~~~~~~~~
ソースコード
#include <stdio.h>
int main(){
int val,quantity;
scanf("%d%d",&val,&quantity);
int fresh[val];
for(int i = 0;i < val;i ++){
scanf("%d",&fresh[i]);
}
for(int i = 0;i < val;i ++){
for(int j = 0;j < val;j ++){
if(fresh[i] < fresh[j]){
int temp = fresh[i];
fresh[i] = fresh[j];
fresh[j] = temp;
}
}
}
int ans = 0;
for(int i = 0;i < quantity;i ++){
if(fresh[i] > 0){
ans += fresh[i];
}
}
printf("%d",ans);
}
toto