結果
| 問題 |
No.5 数字のブロック
|
| コンテスト | |
| ユーザー |
takatowin
|
| 提出日時 | 2017-01-07 15:46:39 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 487 bytes |
| コンパイル時間 | 213 ms |
| コンパイル使用メモリ | 31,104 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-12-17 16:13:19 |
| 合計ジャッジ時間 | 2,455 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 21 WA * 13 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:19:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
19 | scanf("%d %d",&L,&N);
| ~~~~~^~~~~~~~~~~~~~~
main.cpp:22:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
22 | scanf("%d",&b[i]);
| ~~~~~^~~~~~~~~~~~
ソースコード
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
int L,N;
void bubble(int* b){
int i,j,temp;
for(i=N-1;i>0;i--){
for(j=0;j<i;j++)
if(b[j]>b[j+1]){
temp=b[j];
b[j]=b[j+1];
b[j+1]=temp;
}
}
}
int main(void){
int i=0,temp=0,temp1=0;
scanf("%d %d",&L,&N);
int b[N];
for(;i<N;i++){
scanf("%d",&b[i]);
}
bubble(b);
while(temp<L){
temp+=b[temp1];
temp1++;
}
printf("%d\n",temp1-1);
return 0;
}
takatowin