結果
問題 |
No.3097 Azuki Kurai
|
ユーザー |
|
提出日時 | 2025-03-23 07:01:52 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,249 bytes |
コンパイル時間 | 4,526 ms |
コンパイル使用メモリ | 224,168 KB |
実行使用メモリ | 23,808 KB |
最終ジャッジ日時 | 2025-03-23 07:02:49 |
合計ジャッジ時間 | 56,208 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 2 WA * 60 |
ソースコード
#include <bits/stdc++.h> #define rep(i, p, n) for (ll i = p; i < (ll)(n); i++) #define rep2(i, p, n) for (ll i = p; i >= (ll)(n); i--) using namespace std; using ll = long long; using ld = long double; const double pi = 3.141592653589793; const long long inf = 2 * 1e9; const long long linf = 4 * 1e18; const ll mod1 = 1000000007; const ll mod2 = 998244353; template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } // atcoder #include <atcoder/all> using namespace atcoder; using mint1 = modint1000000007; using mint2 = modint998244353; vector<pair<ll, ll>> base = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}}; int main() { ////////////////// ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); ////////////////// ll N, M, K; cin >> N >> M >> K; vector<ll> A(N); rep(i, 0, N) { cin >> A.at(i); } vector<vector<ll>> dp(M + 1, vector<ll>((1 << N), linf)); rep(i, 0, (1 << N)) { dp.at(0).at(i) = 0; rep(j, 0, N) { if (!(i & (1 << j))) { dp.at(0).at(i) += A.at(j); } } } ll now, temp; rep(p, 0, M) { ll B; cin >> B; B--; rep(i, 0, (1 << N)) { for (ll c = i; c; c = (c - 1) & i) { now = i, temp = dp.at(p).at(i); temp += (__builtin_popcount(i) - __builtin_popcount(c)) * K; now |= ((c * 2) - ((c * 2) & (1 << N))); now |= (c / 2); now |= (c % 2) * (1 << (N - 1)); now -= (now & (1 << B)); chmin(dp.at(p + 1).at(now), temp); } now = i, temp = dp.at(p).at(i); rep(j, 0, N) { if (i & (1 << j)) { temp += K; } } now -= (now & (1 << B)); chmin(dp.at(p + 1).at(now), temp); } } rep(i, 0, M) { cout << dp.at(i + 1).at(0) << endl; } }