結果
問題 |
No.5 数字のブロック
|
ユーザー |
|
提出日時 | 2016-11-09 17:29:06 |
言語 | C90 (gcc 12.3.0) |
結果 |
AC
|
実行時間 | 26 ms / 5,000 ms |
コード長 | 426 bytes |
コンパイル時間 | 154 ms |
コンパイル使用メモリ | 21,376 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-18 10:27:10 |
合計ジャッジ時間 | 1,350 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 34 |
コンパイルメッセージ
main.c: In function ‘main’: main.c:4:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 4 | scanf("%d%d",&l,&n); | ^~~~~~~~~~~~~~~~~~~ main.c:9:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 9 | scanf("%d",&a[0]); | ^~~~~~~~~~~~~~~~~ main.c:11:17: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 11 | scanf("%d",&t); | ^~~~~~~~~~~~~~
ソースコード
#include<stdio.h> int main(){ int l,n,i,j,t; scanf("%d%d",&l,&n); int a[n]; for(i=0;i<n;i++){ a[i]=0; } scanf("%d",&a[0]); for(i=1;i<n;i++){ scanf("%d",&t); for(j=i;j>0;j--){ if(a[j-1]<t){ a[j]=a[j-1]; a[j-1]=t; }else{ a[j]=t; break; } } } for(t=0;i>0;i--){ if(a[i-1]<=l){ t++; l-=a[i-1]; }else{ break; } } printf("%d",t); return 0; }