結果
| 問題 |
No.3041 非対称じゃんけん
|
| コンテスト | |
| ユーザー |
kidodesu
|
| 提出日時 | 2025-02-28 22:48:01 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,529 bytes |
| コンパイル時間 | 1,294 ms |
| コンパイル使用メモリ | 116,160 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2025-02-28 22:48:12 |
| 合計ジャッジ時間 | 9,796 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 7 WA * 23 |
ソースコード
//生成AIを用いてPythonからC++に変換しました
#include <iostream>
#include <vector>
#include <bitset>
#include <algorithm> // std::max を使うために追加
#include <cstdint> // uint64_t を使うために追加
using namespace std;
const int L = 63;
const int MAX_N = 15000;
const int MAX_F = 60;
const int MAX_SUM = MAX_N * MAX_F;
const int BITSET_SIZE = (MAX_SUM / L) + 1; // 63ビットごとに管理
vector<uint64_t> dp(BITSET_SIZE, 0);
uint64_t T = (1ULL << L) - 1; // 63ビット分のマスク
// ビットの立っている数をカウント(popcnt)
int popcnt3(uint64_t n) {
return __builtin_popcountll(n); // GCC/Clang の組み込み関数
}
int main() {
int n, f;
cin >> n >> f;
vector<int> A(n), B(n), C(n);
for (int i = 0; i < n; ++i) cin >> A[i];
for (int i = 0; i < n; ++i) cin >> B[i];
for (int i = 0; i < n; ++i) cin >> C[i];
int N = 0;
for (int i = 0; i < n; ++i) {
N += max(A[i], max(B[i], C[i])); // 修正: max を 2 回使う
}
dp[0] |= 1; // 初期状態(和が 0 は可能)
for (int i = 0; i < n; ++i) {
vector<uint64_t> ndp(BITSET_SIZE, 0);
uint64_t tmp = 0;
int ans = 0;
for (int j = 0; j < BITSET_SIZE; ++j) {
tmp |= (dp[j] << A[i]) | (dp[j] << B[i]) | (dp[j] << C[i]);
ndp[j] = tmp & T;
tmp >>= L;
ans += popcnt3(ndp[j]);
}
cout << ans << '\n';
dp = ndp; // 更新
}
return 0;
}
kidodesu