Submission #489288

#TimeUsernameProblemLanguageResultExecution timeMemory
489288ntabc05101Lottery (CEOI18_lot)C++14
0 / 100
352 ms440 KiB
#include<bits/stdc++.h> using namespace std; #define taskname "" int main() { if (fopen(taskname".inp", "r")) { freopen(taskname".inp", "r", stdin); freopen(taskname".out", "w", stdout); } else { if (fopen(taskname".in", "r")) { freopen(taskname".in", "r", stdin); freopen(taskname".out", "w", stdout); } } cin.tie(0)->sync_with_stdio(0); int n, l; cin >> n >> l; int a[n + 1]; a[0] = 0; for (int i = 1; i <= n; i++) { cin >> a[i]; } int q; cin >> q; int k[q], k2[q]; for (int i = 0; i < q; i++) { cin >> k[i]; k2[i] = k[i]; } sort(k2, k2 + q); int prf[n + 1]; prf[0] = 0; int res[n + 1][q]; memset(res, 0, sizeof(res)); for (int j = 1; j < n; j++) { for (int i = 1; i <= n - j; i++) { prf[i] = prf[i - 1] + (a[i] != a[i + j]); } for (int i = 1; i + j + l - 1 <= n; i++) { int p = lower_bound(k2, k2 + q, prf[i + l - 1] - prf[i - 1]) - k2; res[i][p]++; res[i + j][p]++; } } for (int i = 1; i <= n; i++) { for (int j = 1; j < q; j++) { res[i][j] += res[i][j - 1]; } } for (int i = 0; i < q; i++) { for (int j = 1; j <= n - l + 1; j++) { cout << res[j][lower_bound(k2, k2 + q, k[i]) - k2] << " "; } cout << "\n"; } return 0; }

Compilation message (stderr)

lot.cpp: In function 'int main()':
lot.cpp:8:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |   freopen(taskname".inp", "r", stdin);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
lot.cpp:9:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |   freopen(taskname".out", "w", stdout);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
lot.cpp:13:11: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |    freopen(taskname".in", "r", stdin);
      |    ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
lot.cpp:14:11: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |    freopen(taskname".out", "w", stdout);
      |    ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...