結果
問題 |
No.1046 Fruits Rush
|
ユーザー |
![]() |
提出日時 | 2025-04-01 14:41:14 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 518 bytes |
コンパイル時間 | 367 ms |
コンパイル使用メモリ | 28,416 KB |
実行使用メモリ | 7,844 KB |
最終ジャッジ日時 | 2025-04-01 14:41:16 |
合計ジャッジ時間 | 1,265 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 11 WA * 3 |
コンパイルメッセージ
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 ++){ //printf("新鮮さ:%d ans:%d",fresh[i]); if(fresh[i] > 0){ ans += fresh[i]; } } printf("%d",ans); }