結果
問題 | No.2423 Merge Stones |
ユーザー | firiexp |
提出日時 | 2023-07-15 13:54:12 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 258 ms / 4,000 ms |
コード長 | 1,768 bytes |
コンパイル時間 | 997 ms |
コンパイル使用メモリ | 105,876 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-09-17 04:01:51 |
合計ジャッジ時間 | 8,278 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge6 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,816 KB |
testcase_01 | AC | 2 ms
6,940 KB |
testcase_02 | AC | 2 ms
6,944 KB |
testcase_03 | AC | 3 ms
6,944 KB |
testcase_04 | AC | 1 ms
6,940 KB |
testcase_05 | AC | 2 ms
6,944 KB |
testcase_06 | AC | 2 ms
6,944 KB |
testcase_07 | AC | 2 ms
6,944 KB |
testcase_08 | AC | 2 ms
6,944 KB |
testcase_09 | AC | 2 ms
6,940 KB |
testcase_10 | AC | 2 ms
6,940 KB |
testcase_11 | AC | 253 ms
6,940 KB |
testcase_12 | AC | 21 ms
6,940 KB |
testcase_13 | AC | 23 ms
6,940 KB |
testcase_14 | AC | 22 ms
6,940 KB |
testcase_15 | AC | 22 ms
6,940 KB |
testcase_16 | AC | 22 ms
6,940 KB |
testcase_17 | AC | 24 ms
6,940 KB |
testcase_18 | AC | 23 ms
6,940 KB |
testcase_19 | AC | 22 ms
6,940 KB |
testcase_20 | AC | 23 ms
6,944 KB |
testcase_21 | AC | 22 ms
6,940 KB |
testcase_22 | AC | 22 ms
6,940 KB |
testcase_23 | AC | 24 ms
6,944 KB |
testcase_24 | AC | 24 ms
6,940 KB |
testcase_25 | AC | 23 ms
6,940 KB |
testcase_26 | AC | 22 ms
6,940 KB |
testcase_27 | AC | 22 ms
6,940 KB |
testcase_28 | AC | 22 ms
6,940 KB |
testcase_29 | AC | 22 ms
6,944 KB |
testcase_30 | AC | 22 ms
6,940 KB |
testcase_31 | AC | 23 ms
6,940 KB |
testcase_32 | AC | 23 ms
6,940 KB |
testcase_33 | AC | 24 ms
6,944 KB |
testcase_34 | AC | 22 ms
6,944 KB |
testcase_35 | AC | 22 ms
6,940 KB |
testcase_36 | AC | 22 ms
6,940 KB |
testcase_37 | AC | 22 ms
6,944 KB |
testcase_38 | AC | 23 ms
6,944 KB |
testcase_39 | AC | 22 ms
6,944 KB |
testcase_40 | AC | 22 ms
6,940 KB |
testcase_41 | AC | 24 ms
6,944 KB |
testcase_42 | AC | 22 ms
6,944 KB |
testcase_43 | AC | 23 ms
6,940 KB |
testcase_44 | AC | 22 ms
6,940 KB |
testcase_45 | AC | 22 ms
6,940 KB |
testcase_46 | AC | 24 ms
6,944 KB |
testcase_47 | AC | 23 ms
6,944 KB |
testcase_48 | AC | 25 ms
6,944 KB |
testcase_49 | AC | 22 ms
6,940 KB |
testcase_50 | AC | 21 ms
6,940 KB |
testcase_51 | AC | 213 ms
6,944 KB |
testcase_52 | AC | 212 ms
6,940 KB |
testcase_53 | AC | 252 ms
6,940 KB |
testcase_54 | AC | 214 ms
6,940 KB |
testcase_55 | AC | 258 ms
6,940 KB |
testcase_56 | AC | 24 ms
6,944 KB |
testcase_57 | AC | 25 ms
6,940 KB |
testcase_58 | AC | 27 ms
6,940 KB |
testcase_59 | AC | 25 ms
6,944 KB |
testcase_60 | AC | 23 ms
6,940 KB |
testcase_61 | AC | 249 ms
6,940 KB |
testcase_62 | AC | 256 ms
6,944 KB |
testcase_63 | AC | 250 ms
6,944 KB |
testcase_64 | AC | 258 ms
6,940 KB |
testcase_65 | AC | 253 ms
6,940 KB |
testcase_66 | AC | 254 ms
6,944 KB |
testcase_67 | AC | 251 ms
6,940 KB |
testcase_68 | AC | 256 ms
6,948 KB |
testcase_69 | AC | 253 ms
6,944 KB |
testcase_70 | AC | 226 ms
6,944 KB |
testcase_71 | AC | 142 ms
6,944 KB |
testcase_72 | AC | 141 ms
6,944 KB |
ソースコード
#include <iostream> #include <algorithm> #include <map> #include <set> #include <queue> #include <stack> #include <numeric> #include <bitset> #include <cmath> static const int MOD = 1000000007; using ll = long long; using uint = unsigned; using ull = unsigned long long; using namespace std; template<class T> constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208; ll dp[600][601]; int main() { int n, k; cin >> n >> k; vector<int> A(2*n), C(2*n); for (int i = 0; i < n; ++i) { scanf("%d", &A[i]); A[i+n] = A[i]; } vector<ll> S(2*n+1); for (int i = 0; i < 2*n; ++i) { S[i+1] = S[i] + A[i]; } for (int i = 0; i < n; ++i) { scanf("%d", &C[i]); C[i+n] = C[i]; } n *= 2; for (int i = 0; i < n; ++i) { for (int j = i+1; j <= n; ++j) { dp[i][j] = 0; } dp[i][i+1] = (1LL << C[i]); } int half = n/2; for (int len = 2; len <= half; ++len) { for (int l = 0; l+len <= n; ++l) { int r = l+len; for (int mid = l+1; mid < r; ++mid) { ll lval = dp[l][mid], rval = dp[mid][r]; if(lval == 0 || rval == 0) continue; dp[l][r] |= lval & rval; for (int i = 1; i <= k; ++i) { dp[l][r] |= lval & (rval << i); dp[l][r] |= lval & (rval >> i); dp[l][r] |= lval << i & rval; dp[l][r] |= lval >> i & rval; } } } } ll ans = 0; for (int i = 0; i < n; ++i) { for (int j = i+1; j <= n && j-i <= half; ++j) { if(dp[i][j] > 0) ans = max(ans, S[j]-S[i]); } } cout << ans << "\n"; return 0; }