Submission #760918

#TimeUsernameProblemLanguageResultExecution timeMemory
760918MilosMilutinovicLottery (CEOI18_lot)C++14
45 / 100
72 ms65536 KiB
#include <bits/stdc++.h> using namespace std; const int N = 1e4 + 10; int n, d, q, a[N], f[N][N]; int main() { scanf("%d%d", &n, &d); for (int i = 1; i <= n; i++) { scanf("%d", &a[i]); } for (int l = 1; l + d - 1 <= n; l++) { int cnt = 0; for (int i = 1; i <= d; i++) cnt += (a[i] != a[l + i - 1]); for (int r = 1; l + (d - 1) + (r - 1) <= n; r++) { f[r][l + r - 1] = cnt; f[l + r - 1][r] = cnt; cnt -= (a[l + r - 1] != a[r]); cnt += (a[l + r + d - 1] != a[r + d]); } } // for (int i = 1; i + d - 1 <= n; i++) // for (int j = i + 1; j + d - 1 <= n; j++) // printf("i = %d, j = %d diff = %d\n", i, j, f[i][j]); scanf("%d", &q); while (q--) { int k; scanf("%d", &k); for (int i = 1; i + d - 1 <= n; i++) { int cnt = 0; for (int j = 1; j + d - 1 <= n; j++) cnt += (f[i][j] <= k); printf("%d ", cnt - 1); } printf("\n"); } return 0; }

Compilation message (stderr)

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