Submission #1111331

# Submission time Handle Problem Language Result Execution time Memory
1111331 2024-11-12T06:04:41 Z sleepntsheep Topical (NOI23_topical) C
100 / 100
353 ms 37460 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; ++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 4 ms 12624 KB Output is correct
4 Correct 150 ms 37460 KB Output is correct
5 Correct 151 ms 37300 KB Output is correct
6 Correct 163 ms 37288 KB Output is correct
7 Correct 113 ms 25784 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 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 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 4 ms 12732 KB Output is correct
10 Correct 5 ms 12640 KB Output is correct
11 Correct 6 ms 12624 KB Output is correct
12 Correct 4 ms 12624 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 6 ms 12636 KB Output is correct
4 Correct 35 ms 13100 KB Output is correct
5 Correct 31 ms 13000 KB Output is correct
6 Correct 349 ms 35240 KB Output is correct
7 Correct 340 ms 35912 KB Output is correct
8 Correct 341 ms 35244 KB Output is correct
9 Correct 353 ms 35784 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 4 ms 12624 KB Output is correct
4 Correct 150 ms 37460 KB Output is correct
5 Correct 151 ms 37300 KB Output is correct
6 Correct 163 ms 37288 KB Output is correct
7 Correct 113 ms 25784 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 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 4 ms 12732 KB Output is correct
17 Correct 5 ms 12640 KB Output is correct
18 Correct 6 ms 12624 KB Output is correct
19 Correct 4 ms 12624 KB Output is correct
20 Correct 2 ms 12624 KB Output is correct
21 Correct 2 ms 12624 KB Output is correct
22 Correct 6 ms 12636 KB Output is correct
23 Correct 35 ms 13100 KB Output is correct
24 Correct 31 ms 13000 KB Output is correct
25 Correct 349 ms 35240 KB Output is correct
26 Correct 340 ms 35912 KB Output is correct
27 Correct 341 ms 35244 KB Output is correct
28 Correct 353 ms 35784 KB Output is correct
29 Correct 217 ms 19584 KB Output is correct
30 Correct 226 ms 19528 KB Output is correct
31 Correct 315 ms 20416 KB Output is correct
32 Correct 151 ms 19528 KB Output is correct
33 Correct 185 ms 19632 KB Output is correct
34 Correct 230 ms 19624 KB Output is correct
35 Correct 285 ms 20160 KB Output is correct
36 Correct 254 ms 19640 KB Output is correct
37 Correct 284 ms 19628 KB Output is correct
38 Correct 151 ms 20232 KB Output is correct