Submission #320761

#TimeUsernameProblemLanguageResultExecution timeMemory
320761dolphingarlicLottery (CEOI18_lot)C++14
80 / 100
3036 ms1656 KiB
#include <bits/stdc++.h>
using namespace std;

int a[10000], base[10000], ans[10000];

int main() {
	int n, l, q;
	scanf("%d %d", &n, &l);
	for (int i = 0; i < n; i++) scanf("%d", a + i);
	for (int dx = 1; dx <= n - l; dx++) {
		for (int p = 0; p < l; p++) base[dx] += (a[p] != a[dx + p]);
	}
	scanf("%d", &q);
	while (q--) {
		int k;
		scanf("%d", &k);
		for (int dx = 1; dx <= n - l; dx++) {
			int diff = base[dx];
			if (diff <= k) ans[0]++, ans[dx]++;
			for (int i = 1; i <= n - l - dx; i++) {
				int j = i + dx;
				diff += (a[i + l - 1] != a[j + l - 1]) - (a[i - 1] != a[j - 1]);
				if (diff <= k) ans[i]++, ans[j]++;
			}
		}
		for (int i = 0; i <= n - l; i++) printf("%d ", ans[i]);
		printf("\n");
		fill(ans, ans + n - l + 1, 0);
	}
}

Compilation message (stderr)

lot.cpp: In function 'int main()':
lot.cpp:8:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    8 |  scanf("%d %d", &n, &l);
      |  ~~~~~^~~~~~~~~~~~~~~~~
lot.cpp:9:35: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    9 |  for (int i = 0; i < n; i++) scanf("%d", a + i);
      |                              ~~~~~^~~~~~~~~~~~~
lot.cpp:13:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   13 |  scanf("%d", &q);
      |  ~~~~~^~~~~~~~~~
lot.cpp:16:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   16 |   scanf("%d", &k);
      |   ~~~~~^~~~~~~~~~
#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...