結果
| 問題 |
No.5 数字のブロック
|
| ユーザー |
184
|
| 提出日時 | 2014-10-01 02:22:27 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 5,000 ms |
| コード長 | 526 bytes |
| コンパイル時間 | 2,370 ms |
| コンパイル使用メモリ | 67,840 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-11-17 21:58:17 |
| 合計ジャッジ時間 | 1,368 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 34 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:18:14: 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:22: 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 <cstring>
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>
#include <queue>
using namespace std;
//これNo4かもわからない、とりあえず提出してみただけ
int main(){
int w[20000];
int n, l;
scanf("%d %d", &l, &n);
for(int i=0; i<n; i++)
scanf("%d", &w[i]);
sort(w, w + n);
int sum = 0, ans = 0;
for(; sum+w[ans]<=l&&ans<n; ans++)
sum += w[ans];
printf("%d\n", ans);
return 0;
}
184