結果
| 問題 |
No.156 キャンディー・ボックス
|
| コンテスト | |
| ユーザー |
Haijinn
|
| 提出日時 | 2017-01-25 20:39:49 |
| 言語 | C90 (gcc 12.3.0) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 2,000 ms |
| コード長 | 506 bytes |
| コンパイル時間 | 185 ms |
| コンパイル使用メモリ | 21,632 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-05 15:58:35 |
| 合計ジャッジ時間 | 1,065 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 30 |
コンパイルメッセージ
main.c: In function ‘main’:
main.c:20:27: warning: format ‘%lld’ expects argument of type ‘long long int *’, but argument 2 has type ‘int *’ [-Wformat=]
20 | scanf("%lld",&c[i]);
| ~~~^ ~~~~~
| | |
| | int *
| long long int *
| %d
main.c:17:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
17 | scanf("%d%lld",&n,&m);
| ^~~~~~~~~~~~~~~~~~~~~
main.c:20:17: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
20 | scanf("%lld",&c[i]);
| ^~~~~~~~~~~~~~~~~~~
ソースコード
#include<stdio.h>
int main(){
int n;
long long m;
int i;
int j;
int temp;
int b;
int c[100000];
int a=0;
int f=0;
scanf("%d%lld",&n,&m);
for(i=0;i<n;i++){
scanf("%lld",&c[i]);
}
for(i=0;i<n;i++){
for(j=n-1;j>i;j--){
if(c[j]>c[j-1]){
temp=c[j];
c[j]=c[j-1];
c[j-1]=temp;
}
}
}
for(i=n-1;i>=0;i--){
f+=c[i];
/*printf("f=%d\n",f);
printf("a=%d\n",a);*/
if(f>m){
break;
}
a++;
}
printf("%d\n",a);
return 0;
}
Haijinn