結果
| 問題 | No.5 数字のブロック |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-03-01 10:13:49 |
| 言語 | C90 (gcc 15.2.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 553 bytes |
| 記録 | |
| コンパイル時間 | 305 ms |
| コンパイル使用メモリ | 24,376 KB |
| 最終ジャッジ日時 | 2026-02-24 00:26:32 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.c: In function 'main':
main.c:25:1: error: C++ style comments are not allowed in ISO C90
25 | //for(i=0;i<N;i++) /*並び替え確認*/
| ^
main.c:25:1: note: (this will be reported only once per input file)
ソースコード
#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;
}
}
}
//for(i=0;i<N;i++) /*並び替え確認*/
//printf("%d\n",BlockW[i]);
int total=0;
int count=0;
for(i=0;i<N;i++){
if(total <= BoxW){
total = total + BlockW[i];
}
if(total <= BoxW){
count++;
}
}
printf("%d\n",count);
return 0;
}