이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
vector<vector<int>> a, b;
vector<pair<int, int>> g[1000005];
long long int c[1000005], d[1000005], f[1000005];
int main() {
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int n, k;
cin >> n >> k;
a = vector<vector<int>> (n + 1, vector<int>(k + 1, 0));
b = vector<vector<int>> (n + 1, vector<int>(k + 1, 0));
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= k; j++) {
cin >> a[i][j];
g[j].push_back({a[i][j], i});
}
}
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= k; j++) {
cin >> b[i][j];
}
}
for (int i = 1; i <= k; i++) {
sort(g[i].begin(), g[i].end());
}
int res = 0;
while (1) {
int flag = 0;
for (int i = 1; i <= k; i++) {
while (c[i] < n && f[i] >= g[i][c[i]].first) {
int h = g[i][c[i]].second;
d[h]++;
if (d[h] == k) {
for (int j = 1; j <= k; j++) {
f[j] += b[h][j];
}
flag = 1;
res++;
}
c[i]++;
}
}
if (flag == 0) break;
}
cout << res;
}
# | 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... |