結果
| 問題 |
No.914 Omiyage
|
| コンテスト | |
| ユーザー |
oevl
|
| 提出日時 | 2020-04-19 18:19:41 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,063 bytes |
| コンパイル時間 | 2,757 ms |
| コンパイル使用メモリ | 208,276 KB |
| 最終ジャッジ日時 | 2025-01-09 21:41:01 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 WA * 1 |
| other | AC * 16 WA * 2 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 30;
int main() {
int N, M, K;
cin >> N >> M >> K;
int X = (N + 1) / 2, Y = N / 2; assert(X + Y == N);
vector<vector<int>> A(X, vector<int>(M));
vector<vector<int>> B(Y, vector<int>(M));
for(int i = 0; i < X; ++i) {
for(int j = 0; j < M; ++j) cin >> A[i][j];
}
for(int i = 0; i < Y; ++i) {
for(int j = 0; j < M; ++j) cin >> B[i][j];
}
map<int, int> ma, ma2;
auto rec = [&](auto &&rec, int now, int d) -> void {
if(d == X) { ma[now]++; return; }
for(int i = 0; i < M; ++i) rec(rec, now + A[d][i], d + 1);
}; rec(rec, 0, 0);
auto rec2 = [&](auto &&rec2, int now, int d) -> void {
if(d == Y) { ma2[now]++; return; }
for(int i = 0; i < M; ++i) rec2(rec2, now + B[d][i], d + 1);
}; rec2(rec2, 0, 0);
int ans = INF;
for(auto &[v, key] : ma) {
for(int a = 0; a < K; ++a) {
if(ma2[K - a - v]) ans = min(ans, a);
}
}
cout << ans << '\n';
return 0;
}
oevl