結果
問題 |
No.5 数字のブロック
|
ユーザー |
![]() |
提出日時 | 2018-11-12 17:26:33 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 19 ms / 5,000 ms |
コード長 | 313 bytes |
コンパイル時間 | 363 ms |
コンパイル使用メモリ | 23,552 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-11-18 12:42:41 |
合計ジャッジ時間 | 1,260 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 34 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:5:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 5 | scanf("%d%d",&L,&n); | ~~~~~^~~~~~~~~~~~~~ main.cpp:8:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 8 | scanf("%d",&w[i]); | ~~~~~^~~~~~~~~~~~
ソースコード
#include<stdio.h> int main(){ int L,n,i,j,tmp; scanf("%d%d",&L,&n); int w[n]; for (i=0;i<n;i++){ scanf("%d",&w[i]); for (j=i;j!=0&&w[j]<w[j-1];j--) tmp=w[j],w[j]=w[j-1],w[j-1]=tmp; } for (i=0,tmp=0;i<n&&L>=0;i++,tmp++) L -= w[i]; if (L<0) tmp--; printf("%d",tmp); return 0; }