結果
| 問題 |
No.5 数字のブロック
|
| ユーザー |
tekitouk
|
| 提出日時 | 2016-04-08 13:58:28 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 4 ms / 5,000 ms |
| コード長 | 463 bytes |
| コンパイル時間 | 527 ms |
| コンパイル使用メモリ | 64,596 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-18 08:28:52 |
| 合計ジャッジ時間 | 1,328 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 34 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:17:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
17 | scanf("%d",&L);
| ~~~~~^~~~~~~~~
main.cpp:18:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
18 | scanf("%d",&N);
| ~~~~~^~~~~~~~~
main.cpp:25:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
25 | scanf("%d",&w);
| ~~~~~^~~~~~~~~
ソースコード
#include <cstdlib>
#include <cstdio>
#include <ctime>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
vector<int>W;
int main(void){
int L,N;
scanf("%d",&L);
scanf("%d",&N);
int i;
int w;
for (i = 0; i < N; i++) {
scanf("%d",&w);
W.push_back(w);
}
sort(W.begin(),W.end());
int sum = 0;
for (i = 0; i < N; i++) {
sum += W[i];
if (sum > L) { break; }
}
printf("%d\n",i);
return 0;
}
tekitouk