結果
| 問題 |
No.5 数字のブロック
|
| ユーザー |
goodbaton
|
| 提出日時 | 2014-11-15 22:11:23 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 5,000 ms |
| コード長 | 543 bytes |
| コンパイル時間 | 574 ms |
| コンパイル使用メモリ | 67,856 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-11-17 22:01:11 |
| 合計ジャッジ時間 | 1,376 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 34 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:18:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
18 | scanf("%d%d",&L,&N);
| ~~~~~^~~~~~~~~~~~~~
main.cpp:21:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
21 | scanf("%d",&W[i]);
| ~~~~~^~~~~~~~~~~~
ソースコード
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#define INF 100000000000000
using namespace std;
int main(){
int L,N,W[10000],ans=0;
scanf("%d%d",&L,&N);
for(int i=0;i<N;i++){
scanf("%d",&W[i]);
}
sort(W,W+N);
for(int i=0;(L>=W[i] && i<N);i++){
ans++;
L-=W[i];
}
printf("%d\n",ans);
return 0;
}
goodbaton