#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; ++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 |
4 ms |
12880 KB |
Output is correct |
4 |
Correct |
158 ms |
45180 KB |
Output is correct |
5 |
Correct |
151 ms |
45076 KB |
Output is correct |
6 |
Correct |
151 ms |
45128 KB |
Output is correct |
7 |
Correct |
118 ms |
31524 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
12624 KB |
Output is correct |
2 |
Correct |
2 ms |
12624 KB |
Output is correct |
3 |
Correct |
2 ms |
12624 KB |
Output is correct |
4 |
Correct |
2 ms |
12624 KB |
Output is correct |
5 |
Correct |
2 ms |
12624 KB |
Output is correct |
6 |
Correct |
2 ms |
12744 KB |
Output is correct |
7 |
Correct |
5 ms |
12880 KB |
Output is correct |
8 |
Correct |
4 ms |
12840 KB |
Output is correct |
9 |
Correct |
7 ms |
12636 KB |
Output is correct |
10 |
Correct |
4 ms |
12880 KB |
Output is correct |
11 |
Correct |
4 ms |
12880 KB |
Output is correct |
12 |
Incorrect |
5 ms |
12880 KB |
Output isn't correct |
13 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
12624 KB |
Output is correct |
2 |
Correct |
2 ms |
12788 KB |
Output is correct |
3 |
Incorrect |
5 ms |
13136 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 |
4 ms |
12880 KB |
Output is correct |
4 |
Correct |
158 ms |
45180 KB |
Output is correct |
5 |
Correct |
151 ms |
45076 KB |
Output is correct |
6 |
Correct |
151 ms |
45128 KB |
Output is correct |
7 |
Correct |
118 ms |
31524 KB |
Output is correct |
8 |
Correct |
2 ms |
12624 KB |
Output is correct |
9 |
Correct |
2 ms |
12624 KB |
Output is correct |
10 |
Correct |
2 ms |
12624 KB |
Output is correct |
11 |
Correct |
2 ms |
12624 KB |
Output is correct |
12 |
Correct |
2 ms |
12624 KB |
Output is correct |
13 |
Correct |
2 ms |
12744 KB |
Output is correct |
14 |
Correct |
5 ms |
12880 KB |
Output is correct |
15 |
Correct |
4 ms |
12840 KB |
Output is correct |
16 |
Correct |
7 ms |
12636 KB |
Output is correct |
17 |
Correct |
4 ms |
12880 KB |
Output is correct |
18 |
Correct |
4 ms |
12880 KB |
Output is correct |
19 |
Incorrect |
5 ms |
12880 KB |
Output isn't correct |
20 |
Halted |
0 ms |
0 KB |
- |