結果
| 問題 | No.5 数字のブロック |
| コンテスト | |
| ユーザー |
tekitouk
|
| 提出日時 | 2016-04-08 13:59:22 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 4 ms / 5,000 ms |
| コード長 | 495 bytes |
| 記録 | |
| コンパイル時間 | 839 ms |
| コンパイル使用メモリ | 65,824 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-11-18 08:29:04 |
| 合計ジャッジ時間 | 1,711 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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; }
}
string ans = to_string(i);
cout << ans << endl;
return 0;
}
tekitouk