Submission #1111330

# Submission time Handle Problem Language Result Execution time Memory
1111330 2024-11-12T06:04:21 Z sleepntsheep Topical (NOI23_topical) C
100 / 100
389 ms 50248 KB
#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], ii[N], z;
long long a[N];

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:25:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |  scanf("%d%d", &n, &k);
      |  ^~~~~~~~~~~~~~~~~~~~~
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", r_ + i);
      |                                  ^~~~~~~~~~~~~~~~~~~
Main.c:29:34: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |  for (int i = 0; i < n * k; ++i) scanf("%d", u_ + i);
      |                                  ^~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 12624 KB Output is correct
2 Correct 2 ms 12624 KB Output is correct
3 Correct 3 ms 12640 KB Output is correct
4 Correct 145 ms 37552 KB Output is correct
5 Correct 144 ms 37448 KB Output is correct
6 Correct 144 ms 37448 KB Output is correct
7 Correct 123 ms 25684 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 12624 KB Output is correct
2 Correct 2 ms 12624 KB Output is correct
3 Correct 1 ms 12624 KB Output is correct
4 Correct 2 ms 12792 KB Output is correct
5 Correct 2 ms 12624 KB Output is correct
6 Correct 2 ms 12624 KB Output is correct
7 Correct 4 ms 12624 KB Output is correct
8 Correct 4 ms 12624 KB Output is correct
9 Correct 3 ms 12624 KB Output is correct
10 Correct 4 ms 12624 KB Output is correct
11 Correct 4 ms 12624 KB Output is correct
12 Correct 4 ms 12624 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 12624 KB Output is correct
2 Correct 2 ms 12624 KB Output is correct
3 Correct 4 ms 12624 KB Output is correct
4 Correct 33 ms 14520 KB Output is correct
5 Correct 32 ms 14376 KB Output is correct
6 Correct 364 ms 50248 KB Output is correct
7 Correct 381 ms 48968 KB Output is correct
8 Correct 389 ms 50236 KB Output is correct
9 Correct 371 ms 48968 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 12624 KB Output is correct
2 Correct 2 ms 12624 KB Output is correct
3 Correct 3 ms 12640 KB Output is correct
4 Correct 145 ms 37552 KB Output is correct
5 Correct 144 ms 37448 KB Output is correct
6 Correct 144 ms 37448 KB Output is correct
7 Correct 123 ms 25684 KB Output is correct
8 Correct 2 ms 12624 KB Output is correct
9 Correct 2 ms 12624 KB Output is correct
10 Correct 1 ms 12624 KB Output is correct
11 Correct 2 ms 12792 KB Output is correct
12 Correct 2 ms 12624 KB Output is correct
13 Correct 2 ms 12624 KB Output is correct
14 Correct 4 ms 12624 KB Output is correct
15 Correct 4 ms 12624 KB Output is correct
16 Correct 3 ms 12624 KB Output is correct
17 Correct 4 ms 12624 KB Output is correct
18 Correct 4 ms 12624 KB Output is correct
19 Correct 4 ms 12624 KB Output is correct
20 Correct 1 ms 12624 KB Output is correct
21 Correct 2 ms 12624 KB Output is correct
22 Correct 4 ms 12624 KB Output is correct
23 Correct 33 ms 14520 KB Output is correct
24 Correct 32 ms 14376 KB Output is correct
25 Correct 364 ms 50248 KB Output is correct
26 Correct 381 ms 48968 KB Output is correct
27 Correct 389 ms 50236 KB Output is correct
28 Correct 371 ms 48968 KB Output is correct
29 Correct 227 ms 37704 KB Output is correct
30 Correct 242 ms 36904 KB Output is correct
31 Correct 351 ms 35492 KB Output is correct
32 Correct 172 ms 28488 KB Output is correct
33 Correct 226 ms 29516 KB Output is correct
34 Correct 270 ms 29448 KB Output is correct
35 Correct 334 ms 31936 KB Output is correct
36 Correct 269 ms 32552 KB Output is correct
37 Correct 291 ms 35352 KB Output is correct
38 Correct 156 ms 24068 KB Output is correct