// - 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());
long long 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);
}
int res = 0;
while (clock() / (double)CLOCKS_PER_SEC < 0.97) {
shuffle(perm.begin(), perm.end(), rng);
REP (j, k) {
p[j] = 0;
}
bool 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;
}
Compilation message (stderr)
Main.cpp: In function 'int main()':
Main.cpp:22:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
22 | freopen(name".inp", "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:23:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
23 | freopen(name".out", "w", stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |