結果
| 問題 |
No.5 数字のブロック
|
| コンテスト | |
| ユーザー |
Tirol_JPN
|
| 提出日時 | 2016-09-11 17:47:57 |
| 言語 | C90 (gcc 12.3.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 683 bytes |
| コンパイル時間 | 113 ms |
| コンパイル使用メモリ | 21,888 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-17 03:34:35 |
| 合計ジャッジ時間 | 5,357 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | RE * 34 |
コンパイルメッセージ
main.c: In function ‘main’:
main.c:27:17: warning: format ‘%d’ expects argument of type ‘int *’, but argument 2 has type ‘int’ [-Wformat=]
27 | scanf("%d",w[i]);
| ~^ ~~~~
| | |
| | int
| int *
main.c:25:5: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
25 | scanf("%d %d",&l,&n);
| ^~~~~~~~~~~~~~~~~~~~
main.c:27:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
27 | scanf("%d",w[i]);
| ^~~~~~~~~~~~~~~~
ソースコード
#include <stdio.h>
#include <stdlib.h>
// ソート
void sort(int n,int w[]){
int i,j,mini,tmp;
for(i=0;i<n;i++){
mini=i;
for(j=i+1;j<n;j++){
if(w[j]<w[mini]){
mini=j;
}
}
if(mini!=i){
tmp = w[i];
w[i] = w[mini];
w[mini] = tmp;
}
}
}
int main(int argc, char * argv[]){
int l,n,ans=0,i,rest;
int w[10001];
scanf("%d %d",&l,&n);
for(i=0;i<n;i++){
scanf("%d",w[i]);
}
sort(n,w);
rest=l;
while(1){
rest-=w[i];
if(rest<0) break;
ans++;
i++;
}
printf("%d\n",ans);
return 0;
}
Tirol_JPN