Submission #68583068


Source Code Expand

#include <stdio.h>
#include <stdlib.h>

int cmp(const void* x, const void* y) {
	int a = *(const int*)x, b = *(const int*)y;
	return a < b ? -1 : a > b;
}

int main(void) {
	int N, M;
	int* A;
	int* B;
	int i;
	int first = 1;
	int pos = 0;
	if (scanf("%d%d", &N, &M) != 2) return 1;
	A = malloc(sizeof(*A) * N);
	B = malloc(sizeof(*B) * M);
	if (A == NULL || B == NULL) return 2;
	for (i = 0; i < N; i++) {
		if (scanf("%d", &A[i]) != 1) return 1;
	}
	for (i = 0; i < M; i++) {
		if (scanf("%d", &B[i]) != 1) return 1;
	}
	qsort(B, M, sizeof(*B), cmp);
	for (i = 0; i < N; i++) {
		while (pos < M && A[i] > B[pos]) pos++;
		if (pos < M && A[i] == B[pos]) {
			pos++;
		} else {
			printf(" %d" + first, A[i]);
			first = 0;
		}
	}
	if (!first) putchar('\n');
	return 0;
}

Submission Info

Submission Time
Task B - Search and Delete
User mikecat
Language C (gcc 12.2.0)
Score 200
Code Size 810 Byte
Status AC
Exec Time 0 ms
Memory 1740 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 200 / 200
Status
AC × 2
AC × 28
Set Name Test Cases
Sample example_00.txt, example_01.txt
All example_00.txt, example_01.txt, hand_00.txt, hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt
Case Name Status Exec Time Memory
example_00.txt AC 0 ms 1704 KiB
example_01.txt AC 0 ms 1644 KiB
hand_00.txt AC 0 ms 1628 KiB
hand_01.txt AC 0 ms 1588 KiB
hand_02.txt AC 0 ms 1736 KiB
hand_03.txt AC 0 ms 1724 KiB
hand_04.txt AC 0 ms 1504 KiB
hand_05.txt AC 0 ms 1640 KiB
random_00.txt AC 0 ms 1740 KiB
random_01.txt AC 0 ms 1620 KiB
random_02.txt AC 0 ms 1704 KiB
random_03.txt AC 0 ms 1724 KiB
random_04.txt AC 0 ms 1616 KiB
random_05.txt AC 0 ms 1616 KiB
random_06.txt AC 0 ms 1716 KiB
random_07.txt AC 0 ms 1588 KiB
random_08.txt AC 0 ms 1720 KiB
random_09.txt AC 0 ms 1720 KiB
random_10.txt AC 0 ms 1720 KiB
random_11.txt AC 0 ms 1724 KiB
random_12.txt AC 0 ms 1616 KiB
random_13.txt AC 0 ms 1700 KiB
random_14.txt AC 0 ms 1708 KiB
random_15.txt AC 0 ms 1696 KiB
random_16.txt AC 0 ms 1708 KiB
random_17.txt AC 0 ms 1628 KiB
random_18.txt AC 0 ms 1596 KiB
random_19.txt AC 0 ms 1620 KiB