Submission #320762

#TimeUsernameProblemLanguageResultExecution timeMemory
320762dolphingarlicLottery (CEOI18_lot)C++14
80 / 100
3048 ms3832 KiB
#include <bits/stdc++.h> using namespace std; int a[10000], k[100], ans[100][10000]; int main() { int n, l, q; scanf("%d %d", &n, &l); for (int i = 0; i < n; i++) scanf("%d", a + i); scanf("%d", &q); for (int i = 0; i < q; i++) scanf("%d", k + i); for (int dx = 1; dx <= n - l; dx++) { int diff = 0; for (int p = 0; p < l; p++) diff += (a[p] != a[dx + p]); for (int t = 0; t < q; t++) if (diff <= k[t]) ans[t][0]++, ans[t][dx]++; for (int i = 1; i <= n - l - dx; i++) { diff += (a[i + l - 1] != a[i + dx + l - 1]) - (a[i - 1] != a[i + dx - 1]); for (int t = 0; t < q; t++) if (diff <= k[t]) ans[t][i]++, ans[t][i + dx]++; } } for (int t = 0; t < q; t++) { for (int i = 0; i <= n - l; i++) printf("%d ", ans[t][i]); printf("\n"); } }

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:10:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   10 |  scanf("%d", &q);
      |  ~~~~~^~~~~~~~~~
lot.cpp:11:35: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   11 |  for (int i = 0; i < q; i++) scanf("%d", k + 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...