結果
| 問題 |
No.156 キャンディー・ボックス
|
| コンテスト | |
| ユーザー |
Xelmeph
|
| 提出日時 | 2017-01-02 23:59:12 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 734 bytes |
| コンパイル時間 | 681 ms |
| コンパイル使用メモリ | 74,320 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-05 15:58:28 |
| 合計ジャッジ時間 | 1,607 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 30 |
ソースコード
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
template<typename STL> inline void print_STL(STL c, string ab = ""){
cout << ab << '\n';
for(auto t : c) cout << t << ' '; cout << '\n';}
template<typename VEC> inline void import_VEC(VEC& c, int n){
typename VEC::value_type tmp;
for(int i = 0; i < n; ++i){ cin >> tmp; c.push_back(tmp);} }
#define SPRE(x) setprecision(x) // 精度を指定
template<class T> using Matrix = vector<vector<T>>;
int main()
{
cin.tie(0);
ios::sync_with_stdio(false);
int n, m;
vector<int> c;
cin >> n >> m;
import_VEC(c, n);
sort(c.begin(), c.end());
int ans = 0;
for(auto t : c)
if(m >= t){
m-=t;
ans++;
}
cout << ans << '\n';
ans++;
}
Xelmeph