結果
| 問題 |
No.5 数字のブロック
|
| ユーザー |
ふっぴー
|
| 提出日時 | 2017-03-30 16:34:37 |
| 言語 | C90 (gcc 12.3.0) |
| 結果 |
AC
|
| 実行時間 | 197 ms / 5,000 ms |
| コード長 | 574 bytes |
| コンパイル時間 | 150 ms |
| コンパイル使用メモリ | 23,552 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-11-18 10:59:02 |
| 合計ジャッジ時間 | 2,500 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 34 |
コンパイルメッセージ
main.c: In function ‘main’:
main.c:15:1: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
15 | scanf("%d%d",&BoxW,&N);
| ^~~~~~~~~~~~~~~~~~~~~~
main.c:18:1: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
18 | scanf("%d",&BlockW[i]);
| ^~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <stdlib.h>
#define INF 1000000000;
#include <stdio.h>
int main(void)
{
int BoxW,N,BlockW[10000],i;
scanf("%d%d",&BoxW,&N);
for(i=0;i<N;i++){
scanf("%d",&BlockW[i]);
}
int j,temp;
for(i=0;i<N;i++){
for(j=i+1;j<N;j++){
if( BlockW[i] > BlockW[j] ){
temp= BlockW[i];
BlockW[i]=BlockW[j];
BlockW[j]=temp;
}
}
}
int total=0;
int count=0;
for(i=0;i<N;i++){
total = total + BlockW[i];
if(total <= BoxW){
count++;
}else{
break;
}
}
printf("%d\n",count);
return 0;
}
ふっぴー