結果
問題 | No.393 2本の竹 |
ユーザー |
|
提出日時 | 2016-10-21 15:39:27 |
言語 | C++14 (gcc 11.2.0 + boost 1.78.0) |
結果 |
AC
|
実行時間 | 59 ms / 1,000 ms |
コード長 | 1,152 bytes |
コンパイル時間 | 612 ms |
使用メモリ | 3,556 KB |
最終ジャッジ日時 | 2022-12-28 15:51:37 |
合計ジャッジ時間 | 2,163 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge14 |
テストケース
テストケース表示入力 | 結果 | 実行時間 使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
3,472 KB |
testcase_01 | AC | 1 ms
3,480 KB |
testcase_02 | AC | 2 ms
3,496 KB |
testcase_03 | AC | 1 ms
3,372 KB |
testcase_04 | AC | 1 ms
3,548 KB |
testcase_05 | AC | 2 ms
3,452 KB |
testcase_06 | AC | 2 ms
3,476 KB |
testcase_07 | AC | 1 ms
3,428 KB |
testcase_08 | AC | 2 ms
3,524 KB |
testcase_09 | AC | 59 ms
3,492 KB |
testcase_10 | AC | 12 ms
3,536 KB |
testcase_11 | AC | 20 ms
3,508 KB |
testcase_12 | AC | 26 ms
3,556 KB |
testcase_13 | AC | 13 ms
3,484 KB |
testcase_14 | AC | 8 ms
3,524 KB |
testcase_15 | AC | 2 ms
3,432 KB |
testcase_16 | AC | 4 ms
3,392 KB |
testcase_17 | AC | 2 ms
3,384 KB |
testcase_18 | AC | 2 ms
3,376 KB |
testcase_19 | AC | 2 ms
3,516 KB |
testcase_20 | AC | 2 ms
3,444 KB |
testcase_21 | AC | 2 ms
3,496 KB |
testcase_22 | AC | 32 ms
3,540 KB |
testcase_23 | AC | 12 ms
3,532 KB |
testcase_24 | AC | 2 ms
3,524 KB |
testcase_25 | AC | 1 ms
3,428 KB |
testcase_26 | AC | 1 ms
3,496 KB |
testcase_27 | AC | 55 ms
3,544 KB |
ソースコード
#include <iostream> #include <vector> #include <algorithm> #define repeat(i,n) for (int i = 0; (i) < (n); ++(i)) #define repeat_reverse(i,n) for (int i = (n)-1; (i) >= 0; --(i)) #define whole(f,x,...) ([&](decltype((x)) y) { return (f)(begin(y), end(y), ## __VA_ARGS__); })(x) using namespace std; int main() { int dataset; cin >> dataset; while (dataset --) { // input int n1, n2, m; cin >> n1 >> n2 >> m; vector<int> a(m); repeat (i,m) cin >> a[i]; // roughly estimate whole(sort, a); int acc = 0; int cnt = 0; while (cnt < m and acc + a[cnt] <= n1 + n2) { acc += a[cnt]; ++ cnt; } // check the boundary vector<bool> dp(n1+1); dp[0] = true; repeat (j, cnt) { repeat_reverse (i, n1) if (dp[i]) { if (i + a[j] < n1+1) { dp[i + a[j]] = true; } } } int last = n1; while (not dp[last]) -- last; bool found = (acc - last <= n2); // output cout << (cnt - not found) << endl; } return 0; }