Submission #706480

# Submission time Handle Problem Language Result Execution time Memory
706480 2023-03-06T17:22:11 Z rainboy Exhibition (JOI19_ho_t2) C
100 / 100
90 ms 5260 KB
#include <stdio.h>

#define N	100000
#define M	100000

unsigned int X = 12345;

int rand_() {
	return (X *= 3) >> 1;
}

int ss[N], vv[N], cc[N];

int compare_i(int i1, int i2) {
	return vv[i1] != vv[i2] ? vv[i1] - vv[i2] : ss[i1] - ss[i2];
}

int compare_j(int j1, int j2) {
	return cc[j1] - cc[j2];
}

int (*compare)(int, int);

void sort(int *ii, int l, int r) {
	while (l < r) {
		int i = l, j = l, k = r, i_ = ii[l + rand_() % (r - l)], tmp;

		while (j < k) {
			int c = compare(ii[j], i_);

			if (c == 0)
				j++;
			else if (c < 0) {
				tmp = ii[i], ii[i] = ii[j], ii[j] = tmp;
				i++, j++;
			} else {
				k--;
				tmp = ii[j], ii[j] = ii[k], ii[k] = tmp;
			}
		}
		sort(ii, l, i);
		l = k;
	}
}

int main() {
	static int ii[N], jj[M];
	int n, m, i, j;

	scanf("%d%d", &n, &m);
	for (i = 0; i < n; i++)
		scanf("%d%d", &ss[i], &vv[i]);
	for (i = 0; i < n; i++)
		ii[i] = i;
	compare = compare_i, sort(ii, 0, n);
	for (j = 0; j < m; j++)
		scanf("%d", &cc[j]);
	for (j = 0; j < m; j++)
		jj[j] = j;
	compare = compare_j, sort(jj, 0, m);
	for (i = n - 1, j = m - 1; j >= 0; j--) {
		while (i >= 0 && ss[ii[i]] > cc[jj[j]])
			i--;
		if (i < 0)
			break;
		i--;
	}
	printf("%d\n", m - 1 - j);
	return 0;
}

Compilation message

joi2019_ho_t2.c: In function 'main':
joi2019_ho_t2.c:50:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   50 |  scanf("%d%d", &n, &m);
      |  ^~~~~~~~~~~~~~~~~~~~~
joi2019_ho_t2.c:52:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   52 |   scanf("%d%d", &ss[i], &vv[i]);
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
joi2019_ho_t2.c:57:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   57 |   scanf("%d", &cc[j]);
      |   ^~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 292 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 292 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 336 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 304 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 300 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 304 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 212 KB Output is correct
34 Correct 1 ms 304 KB Output is correct
35 Correct 1 ms 212 KB Output is correct
36 Correct 1 ms 340 KB Output is correct
37 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 292 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 336 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 304 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 300 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 304 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 212 KB Output is correct
34 Correct 1 ms 304 KB Output is correct
35 Correct 1 ms 212 KB Output is correct
36 Correct 1 ms 340 KB Output is correct
37 Correct 1 ms 340 KB Output is correct
38 Correct 69 ms 5016 KB Output is correct
39 Correct 53 ms 5016 KB Output is correct
40 Correct 55 ms 5016 KB Output is correct
41 Correct 75 ms 5112 KB Output is correct
42 Correct 89 ms 5044 KB Output is correct
43 Correct 78 ms 5124 KB Output is correct
44 Correct 67 ms 5068 KB Output is correct
45 Correct 70 ms 5040 KB Output is correct
46 Correct 74 ms 4988 KB Output is correct
47 Correct 62 ms 4584 KB Output is correct
48 Correct 53 ms 4540 KB Output is correct
49 Correct 56 ms 4064 KB Output is correct
50 Correct 52 ms 4228 KB Output is correct
51 Correct 77 ms 5076 KB Output is correct
52 Correct 68 ms 5120 KB Output is correct
53 Correct 72 ms 5020 KB Output is correct
54 Correct 53 ms 5120 KB Output is correct
55 Correct 89 ms 5200 KB Output is correct
56 Correct 41 ms 3376 KB Output is correct
57 Correct 30 ms 1916 KB Output is correct
58 Correct 34 ms 3304 KB Output is correct
59 Correct 40 ms 3364 KB Output is correct
60 Correct 29 ms 2004 KB Output is correct
61 Correct 45 ms 3240 KB Output is correct
62 Correct 77 ms 5012 KB Output is correct
63 Correct 90 ms 5068 KB Output is correct
64 Correct 82 ms 5028 KB Output is correct
65 Correct 67 ms 5120 KB Output is correct
66 Correct 83 ms 5200 KB Output is correct
67 Correct 84 ms 5068 KB Output is correct
68 Correct 72 ms 5004 KB Output is correct
69 Correct 66 ms 5080 KB Output is correct
70 Correct 72 ms 5068 KB Output is correct
71 Correct 62 ms 5020 KB Output is correct
72 Correct 73 ms 5260 KB Output is correct
73 Correct 61 ms 5028 KB Output is correct