Submission #522116

#TimeUsernameProblemLanguageResultExecution timeMemory
522116LucaDantasLottery (CEOI18_lot)C++17
35 / 100
933 ms844 KiB
#include <cstdio>
#include <cassert>

constexpr int maxn = 1e4+10;

int a[maxn], dist[maxn<<1], qtd[maxn], n;

void add(int x) {
	for(int i = 0; i < n; i++)
		if(a[i] != a[x]) ++dist[i - x + maxn]; // adiciono o maxn pra normalizar no meio
}

void rmv(int x) {
	for(int i = 0; i < n; i++)
		if(a[i] != a[x]) --dist[i - x + maxn]; // adiciono o maxn pra normalizar no meio
}

int main() {
	int l; scanf("%d %d", &n, &l);
	for(int i = 0; i < n; i++)
		scanf("%d", a+i);

	for(int i = 0; i < l; i++)
		add(i);

	int q; scanf("%d", &q); // testando q == 1
	assert(q == 1); // só pra so resolver esse caso com ctz e quitar o resto logo
	int val_q; scanf("%d", &val_q);

	for(int i = 0; i < n-l+1; i++) {
		int aq = 0;
		for(int j = maxn-i; j < maxn + n-l+1-i; j++)
			aq += (j != maxn ? dist[j] <= val_q : 0);
		printf("%d ", aq);

		rmv(i);
		add(i+l);
	}
	puts("");
}

Compilation message (stderr)

lot.cpp: In function 'int main()':
lot.cpp:19:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |  int l; scanf("%d %d", &n, &l);
      |         ~~~~~^~~~~~~~~~~~~~~~~
lot.cpp:21:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |   scanf("%d", a+i);
      |   ~~~~~^~~~~~~~~~~
lot.cpp:26:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |  int q; scanf("%d", &q); // testando q == 1
      |         ~~~~~^~~~~~~~~~
lot.cpp:28:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   28 |  int val_q; scanf("%d", &val_q);
      |             ~~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...