QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#415622 | #7185. Poor Students | pandapythoner | WA | 369ms | 3792kb | C++14 | 1.5kb | 2024-05-21 06:21:10 | 2024-05-21 06:21:11 |
Judging History
answer
#pragma GCC optimize("Ofast,urnoll-loops")
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define flt double
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
const ll inf = 1e18;
mt19937 rnd(234);
int n, k;
vector<int> p;
vector<vector<ll>> c;
vector<ll> a;
vector<ll> f;
vector<ll> cnt;
ll solve() {
vector<int> prm(n);
for (int i = 0; i < n; i += 1) {
prm[i] = i;
}
ll rs = inf;
for (int itr = 0; itr < 10000; itr += 1) {
shuffle(all(prm), rnd);
cnt.assign(k, 0);
ll sm = 0;
for (auto i : prm) {
ll opt = -1;
for (int j = 0; j < k; j += 1) {
if (cnt[j] == a[j]) {
continue;
}
if (opt == -1 || c[i][j] < c[i][opt]) {
opt = j;
}
}
assert(opt != -1);
cnt[opt] += 1;
sm += c[i][opt];
}
rs = min(rs, sm);
}
return rs;
}
int32_t main() {
if (1) {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}
cin >> n >> k;
c.assign(n, vector<ll>(k));
for (int i = 0; i < n; i += 1) {
for (int j = 0; j < k; j += 1) {
cin >> c[i][j];
}
}
a.resize(k);
for (int i = 0; i < k; i += 1) {
cin >> a[i];
}
ll rs = solve();
cout << rs << "\n";
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3508kb
input:
6 2 1 2 1 3 1 4 1 5 1 6 1 7 3 4
output:
12
result:
ok answer is '12'
Test #2:
score: 0
Accepted
time: 1ms
memory: 3792kb
input:
3 3 1 2 3 2 4 6 6 5 4 1 1 1
output:
8
result:
ok answer is '8'
Test #3:
score: -100
Wrong Answer
time: 369ms
memory: 3752kb
input:
1000 10 734 303 991 681 755 155 300 483 702 442 237 256 299 675 671 757 112 853 759 233 979 340 288 377 718 199 935 666 576 842 537 363 592 349 494 961 864 727 84 813 340 78 600 492 118 421 478 925 552 617 517 589 716 7 928 638 258 297 706 787 266 746 913 978 436 859 701 951 137 44 815 336 471 720 2...
output:
99153
result:
wrong answer expected '92039', found '99153'