Submission #503233

# Submission time Handle Problem Language Result Execution time Memory
503233 2022-01-07T14:43:22 Z rainboy Osumnjičeni (COCI21_osumnjiceni) C
0 / 110
111 ms 4988 KB
#include <stdio.h>

#define N	200000

int max(int a, int b) { return a > b ? a : b; }

unsigned int X = 12345;

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

int xx[N * 2];

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)
			if (xx[ii[j]] == xx[i_])
				j++;
			else if (xx[ii[j]] < xx[i_]) {
				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 * 2], dd[N * 2];
	int n, q, i, x, ans;

	scanf("%d", &n);
	for (i = 0; i < n; i++)
		scanf("%d%d", &xx[i << 1 | 0], &xx[i << 1 | 1]), xx[i << 1 | 1]++;
	for (i = 0; i < n * 2; i++)
		ii[i] = i;
	sort(ii, 0, n * 2);
	for (i = 0, x = 0; i < n * 2; i++)
		xx[ii[i]] = i + 1 == n * 2 || xx[ii[i + 1]] != xx[ii[i]] ? x++ : x;
	for (i = 0; i < n; i++)
		dd[xx[i << 1 | 0]]++, dd[xx[i << 1 | 1]]--;
	for (i = 1; i < n * 2; i++)
		dd[i] += dd[i - 1];
	ans = 0;
	for (i = 0; i < n * 2; i++)
		ans = max(ans, dd[i]);
	printf("%d\n", ans);
	scanf("%d", &q);
	return 0;
}

Compilation message

Main.c: In function 'main':
Main.c:38:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   38 |  scanf("%d", &n);
      |  ^~~~~~~~~~~~~~~
Main.c:40:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   40 |   scanf("%d%d", &xx[i << 1 | 0], &xx[i << 1 | 1]), xx[i << 1 | 1]++;
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.c:54:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   54 |  scanf("%d", &q);
      |  ^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 106 ms 4788 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 111 ms 4988 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 106 ms 4788 KB Output isn't correct
2 Halted 0 ms 0 KB -