Submission #522128

#TimeUsernameProblemLanguageResultExecution timeMemory
522128LucaDantasLottery (CEOI18_lot)C++17
80 / 100
3061 ms5272 KiB
#include <cstdio>
#include <vector>
#include <algorithm>

constexpr int maxn = 1e4+10, maxq = 105;

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 prox[maxn], ans[maxn][maxq];

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);
	std::vector<int> queries(q);
	for(int i = 0; i < q; i++)
		scanf("%d", &queries[i]);

	for(int i = 0; i < n-l+1; i++) {
		for(int j = maxn-i; j < maxn + n-l+1-i; j++)
			for(int k = 0; k < q; k++)
				ans[i][k] += (j != maxn ? dist[j] <= queries[k] : 0);	

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

	for(int j = 0; j < q; j++) {
		for(int i = 0; i < n-l+1; i++)
			printf("%d ", ans[i][j]);
		puts("");
	}
}

Compilation message (stderr)

lot.cpp: In function 'int main()':
lot.cpp:22:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |  int l; scanf("%d %d", &n, &l);
      |         ~~~~~^~~~~~~~~~~~~~~~~
lot.cpp:24:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |   scanf("%d", a+i);
      |   ~~~~~^~~~~~~~~~~
lot.cpp:29:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |  int q; scanf("%d", &q);
      |         ~~~~~^~~~~~~~~~
lot.cpp:32:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |   scanf("%d", &queries[i]);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~
#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...