#include <stdio.h>
#include <stdlib.h>
#define N (1<<20)
int n, k, r_[N], u_[N], *r[N], *u[N], focus_topic, oc_[N], *oc[N], c[N], a[N], ii[N], z;
int cmpr(const void *i, const void *j) {
return r[*(const int*)i][focus_topic] - r[*(const int*)j][focus_topic];
}
void check(int topic) {
while (ii[topic] < n && r[oc[topic][ii[topic]]][topic] <= a[topic]) {
if (k == ++c[oc[topic][ii[topic]]]) {
++z;
for (int jj = 0; jj < k; ++jj)
a[jj] += u[oc[topic][ii[topic]]][jj];
}
++ii[topic];
}
}
int main() {
scanf("%d%d", &n, &k);
for (int j = 0, i = 0; i < n; ++i, j += k) r[i] = r_ + j, u[i] = u_ + j;
for (int i = 0; i < n * k; ++i) scanf("%d", r_ + i);
for (int i = 0; i < n * k; ++i) scanf("%d", u_ + i);
for (int i = 0, j = 0; i < k; ++i, j += n) {
oc[i] = oc_ + j;
for (int l = 0; l < n; ++l)
oc[i][l] = l;
focus_topic = i;
qsort(oc[i], n, sizeof **oc, cmpr);
}
for (int j = 0; j <= n * 2; ++j)
for (int i = 0; i < k; ++i)
check(i);
printf("%d", z);
}
Compilation message
Main.c: In function 'main':
Main.c:24:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
24 | scanf("%d%d", &n, &k);
| ^~~~~~~~~~~~~~~~~~~~~
Main.c:27:34: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
27 | for (int i = 0; i < n * k; ++i) scanf("%d", r_ + i);
| ^~~~~~~~~~~~~~~~~~~
Main.c:28:34: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
28 | for (int i = 0; i < n * k; ++i) scanf("%d", u_ + i);
| ^~~~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
12624 KB |
Output is correct |
2 |
Correct |
2 ms |
12624 KB |
Output is correct |
3 |
Correct |
3 ms |
12624 KB |
Output is correct |
4 |
Correct |
166 ms |
33356 KB |
Output is correct |
5 |
Correct |
144 ms |
33456 KB |
Output is correct |
6 |
Correct |
172 ms |
33352 KB |
Output is correct |
7 |
Correct |
129 ms |
25672 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
12796 KB |
Output is correct |
2 |
Correct |
2 ms |
12624 KB |
Output is correct |
3 |
Correct |
2 ms |
12852 KB |
Output is correct |
4 |
Correct |
2 ms |
12792 KB |
Output is correct |
5 |
Correct |
2 ms |
12624 KB |
Output is correct |
6 |
Correct |
3 ms |
12624 KB |
Output is correct |
7 |
Correct |
4 ms |
12624 KB |
Output is correct |
8 |
Correct |
4 ms |
12724 KB |
Output is correct |
9 |
Correct |
4 ms |
12792 KB |
Output is correct |
10 |
Correct |
4 ms |
12624 KB |
Output is correct |
11 |
Correct |
4 ms |
12624 KB |
Output is correct |
12 |
Incorrect |
6 ms |
12624 KB |
Output isn't correct |
13 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
12792 KB |
Output is correct |
2 |
Correct |
2 ms |
12624 KB |
Output is correct |
3 |
Incorrect |
4 ms |
12624 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
12624 KB |
Output is correct |
2 |
Correct |
2 ms |
12624 KB |
Output is correct |
3 |
Correct |
3 ms |
12624 KB |
Output is correct |
4 |
Correct |
166 ms |
33356 KB |
Output is correct |
5 |
Correct |
144 ms |
33456 KB |
Output is correct |
6 |
Correct |
172 ms |
33352 KB |
Output is correct |
7 |
Correct |
129 ms |
25672 KB |
Output is correct |
8 |
Correct |
2 ms |
12796 KB |
Output is correct |
9 |
Correct |
2 ms |
12624 KB |
Output is correct |
10 |
Correct |
2 ms |
12852 KB |
Output is correct |
11 |
Correct |
2 ms |
12792 KB |
Output is correct |
12 |
Correct |
2 ms |
12624 KB |
Output is correct |
13 |
Correct |
3 ms |
12624 KB |
Output is correct |
14 |
Correct |
4 ms |
12624 KB |
Output is correct |
15 |
Correct |
4 ms |
12724 KB |
Output is correct |
16 |
Correct |
4 ms |
12792 KB |
Output is correct |
17 |
Correct |
4 ms |
12624 KB |
Output is correct |
18 |
Correct |
4 ms |
12624 KB |
Output is correct |
19 |
Incorrect |
6 ms |
12624 KB |
Output isn't correct |
20 |
Halted |
0 ms |
0 KB |
- |