Submission #43875

# Submission time Handle Problem Language Result Execution time Memory
43875 2018-03-26T15:18:23 Z kdk8361 cmp (balkan11_cmp) C++17
100 / 100
2055 ms 82652 KB
#include "cmp.h"

int shif[4] = { 480,48,6,1 };
int base[4] = { 50,30,10,1 };
int bi[4] = { 8,9,7,5 };

void remember(int n) {
	for (int i = 0; i < 4; i++) {
		bit_set(base[i] + n / shif[i]);
		n %= shif[i];
	}
}

int compare(int b) {
	int cur[4] = { 0, };
	for (int i = 0; i < 4; i++) {
		cur[i] = b / shif[i];
		b %= shif[i];
	}
	for (int i = 0; i < 4; i++) {
		if (bit_get(base[i] + cur[i])) 
			continue;
		if (cur[i] > bi[i] / 2) {
			int l = base[i] + cur[i] + 1, r = base[i] + bi[i];
			for (; l <= r; l++) 
				if (bit_get(l)) return -1;
			return 1;
		}
		int l = base[i], r = base[i] + cur[i] - 1;
		for (; l <= r; l++) 
			if (bit_get(l)) return 1;
		return -1;
	}
	return 0;
}

# Verdict Execution time Memory Grader output
1 Correct 2055 ms 82652 KB Output is correct - maxAccess = 10, score = 100