結果
問題 | No.393 2本の竹 |
ユーザー |
![]() |
提出日時 | 2020-06-02 17:36:19 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 96 ms / 1,000 ms |
コード長 | 908 bytes |
コンパイル時間 | 1,385 ms |
コンパイル使用メモリ | 165,072 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-11-24 04:47:42 |
合計ジャッジ時間 | 2,681 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 28 |
ソースコード
/*** @FileName a.cpp* @Author kanpurin* @Created 2020.06.02 17:36:16**/#include "bits/stdc++.h"using namespace std;typedef long long ll;int main() {int d;cin >> d;while(d--) {int n1,n2;cin >> n1 >> n2;int m;cin >> m;vector<bool> v(n1+1,false);v[0] = true;vector<int> a(m);for (int i = 0; i < m; i++) {cin >> a[i];}sort(a.begin(), a.end());ll sum = 0;int ans = 0;int now = 0;for (int i = 0; i < m; i++) {sum += a[i];for (int j = n1; j >= a[i]; j--) {v[j] = v[j] | v[j - a[i]];if (v[j]) {now = max(now,j);}}if (sum - now <= n2) {ans = i + 1;}}cout << ans << endl;}return 0;}