結果
問題 |
No.5 数字のブロック
|
ユーザー |
![]() |
提出日時 | 2025-03-03 10:00:45 |
言語 | C (gcc 13.3.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 591 bytes |
コンパイル時間 | 432 ms |
コンパイル使用メモリ | 25,728 KB |
実行使用メモリ | 8,612 KB |
最終ジャッジ日時 | 2025-03-03 10:00:52 |
合計ジャッジ時間 | 5,850 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | RE * 34 |
コンパイルメッセージ
main.c: In function ‘main’: main.c:8:30: warning: format ‘%d’ expects argument of type ‘int *’, but argument 2 has type ‘int’ [-Wformat=] 8 | int result = scanf("%d",w[i]); | ~^ ~~~~ | | | | | int | int * main.c:4:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 4 | scanf("%d %d\n",&l,&n); | ^~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <stdio.h> void main(void){ int l = 0, n = 0; scanf("%d %d\n",&l,&n); int w[n]; int i = 0; for(i = 0;i < n ; i++){ int result = scanf("%d",w[i]); if(result == 2){ w[i] = 0; } } for(i = 0;i < n ; i++){ for(int j = 0 ; j < n ; j++ ){ if( w[i] > w[j] ){ int sum = w[i]; w[i] = w[j]; w[j] = sum; } } } for(i = 0;i < n;i++){ l = l - w[i]; if(l <= 0){ break; } } printf("%d",i); }