Submission #151004

# Submission time Handle Problem Language Result Execution time Memory
151004 2019-09-01T14:25:56 Z JustInCase List of Unique Integers (FXCUP4_unique) C++17
100 / 100
2 ms 508 KB
#include <bits/stdc++.h>

#ifdef LOCAL
	#include "grader.cpp"
#else
	#include "unique.h"
#endif

#define pick_unique PickUnique
#define unique_count UniqueCount
#define int32_t int
#define int64_t long long

std::vector< int32_t > pick_unique(int32_t n) {
	std::vector< int32_t > cntFront(n), cntBack(n), res(n, 0);
	for(int32_t i = 0; i < n; i++) {
		cntFront[i] = unique_count(0, i);
		cntBack[i] = unique_count(i, n - 1);
	}

	for(int32_t i = 0; i < n; i++) {
		if(i == 0) {
			if(cntBack[i] > cntBack[i + 1]) {
				res[i] = 1;
			}
		}
		else if(i == n - 1) {
			if(cntFront[i] > cntFront[i - 1]) {
				res[i] = 1;
			}
		}
		else {
			if(cntFront[i] > cntFront[i - 1] && cntBack[i] > cntBack[i + 1]) {
				res[i] = 1;
			}
		}
	}

	return res;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Correct : C = 4
2 Correct 2 ms 248 KB Correct : C = 10
3 Correct 2 ms 252 KB Correct : C = 50
4 Correct 2 ms 376 KB Correct : C = 100
5 Correct 2 ms 248 KB Correct : C = 100
6 Correct 2 ms 380 KB Correct : C = 154
7 Correct 2 ms 376 KB Correct : C = 200
8 Correct 2 ms 504 KB Correct : C = 300
9 Correct 2 ms 508 KB Correct : C = 356
10 Correct 2 ms 380 KB Correct : C = 400
11 Correct 2 ms 504 KB Correct : C = 400
12 Correct 2 ms 376 KB Correct : C = 400
13 Correct 2 ms 504 KB Correct : C = 400
14 Correct 2 ms 376 KB Correct : C = 400
15 Correct 2 ms 376 KB Correct : C = 400