# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1268285 | Art | Topical (NOI23_topical) | C++20 | 0 ms | 0 KiB |
// - Art -
#include <bits/stdc++.h>
#define el cout << '\n'
#define FOR(i, a, b) for (int i = (a), _b = (b); i <= _b; ++i)
#define REV(i, b, a) for (int i = (b), _a = (a); i >= _a; --i)
#define REP(i, c) for (int i = 0, _c = (c); i < _c; ++i)
const int N = 1e6 + 7;
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int p[N];
int main() {
#define name "art"
if (fopen(name".inp", "r")) {
freopen(name".inp", "r", stdin);
freopen(name".out", "w", stdout);
}
ios_base::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
int n, k;
cin >> n >> k;
vector<vector<int>> a(n, vector<int>(2 * k, 0));
REP (i, n) REP (j, k) {
cin >> a[i][j];
}
REP (i, n) FOR (j, k, 2 * k - 1) {
cin >> a[i][j];
}
vector<int> perm;
REP (i, n) {
perm.emplace_back(i);
}
while (clock() / (double)CLOCKS_PER_SEC < 0.98) {
shuffle(perm.begin(), perm.end(), rng);
REP (j, k) {
p[j] = 0;
}
ok = true;
int tmp = 0;
REP (x, n) {
int i = perm[x];
REP (j, k) {
if (p[j] < a[i][j]) {
ok = false; break;
}
}
if (!ok) {
break;
}
FOR (j, k, 2 * k - 1) {
p[j - k] += a[i][j];
}
++tmp;
}
res = max(res, tmp);
}
cout << res, el;
return 0;
}