結果
| 問題 |
No.156 キャンディー・ボックス
|
| コンテスト | |
| ユーザー |
hogeover30
|
| 提出日時 | 2015-02-27 00:09:33 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 316 bytes |
| コンパイル時間 | 597 ms |
| コンパイル使用メモリ | 51,348 KB |
| 最終ジャッジ日時 | 2024-11-14 19:00:27 |
| 合計ジャッジ時間 | 1,292 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:8:9: error: ‘vector’ was not declared in this scope
8 | vector<int> c(n);
| ^~~~~~
main.cpp:3:1: note: ‘std::vector’ is defined in header ‘<vector>’; did you forget to ‘#include <vector>’?
2 | #include <algorithm>
+++ |+#include <vector>
3 | using namespace std;
main.cpp:8:16: error: expected primary-expression before ‘int’
8 | vector<int> c(n);
| ^~~
main.cpp:9:21: error: ‘c’ was not declared in this scope
9 | for(int& v: c) cin>>v;
| ^
main.cpp:10:20: error: ‘c’ was not declared in this scope
10 | sort(begin(c), end(c));
| ^
ソースコード
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
int n, m;
while (cin>>n>>m) {
vector<int> c(n);
for(int& v: c) cin>>v;
sort(begin(c), end(c));
for(int i=1;i<n;++i) c[i]+=c[i-1];
cout<<upper_bound(begin(c), end(c), m)-begin(c)<<endl;
}
}
hogeover30