結果
| 問題 |
No.5 数字のブロック
|
| ユーザー |
Maeda
|
| 提出日時 | 2025-03-03 09:31:41 |
| 言語 | C (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 512 bytes |
| コンパイル時間 | 400 ms |
| コンパイル使用メモリ | 25,088 KB |
| 実行使用メモリ | 8,612 KB |
| 最終ジャッジ日時 | 2025-03-03 09:31:44 |
| 合計ジャッジ時間 | 2,472 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 7 WA * 27 |
コンパイルメッセージ
main.c: In function ‘main’:
main.c:4:5: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
4 | scanf("%d\n",&l);
| ^~~~~~~~~~~~~~~~
main.c:6:5: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
6 | scanf("%d\n",&n);
| ^~~~~~~~~~~~~~~~
main.c:10:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
10 | scanf("%d ",&w[i] );
| ^~~~~~~~~~~~~~~~~~~
ソースコード
#include <stdio.h>
void main(void){
int l = 0 ;
scanf("%d\n",&l);
int n = 0;
scanf("%d\n",&n);
int w[n];
int i;
for(i = 0 ; i < n ; i++ ){
scanf("%d ",&w[i] );
}
for(int i = 0 ; i < n;i++){
for(int j = 0 ; j < i ; j++ ){
if(w[i] < w[j]){
int sum = w[i];
w[i] = w[j];
w[j] = sum;
}
}
}
i = 0;
while(l > 0){
l = l - w[i];
i++;
}
printf("%d\n",i);
}
Maeda