# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1000586 |
2024-06-17T21:57:45 Z |
codefox |
Lottery (CEOI18_lot) |
C++14 |
|
202 ms |
860 KB |
#include<bits/stdc++.h>
using namespace std;
#define pii pair<int, int>
int main()
{
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
int n, l;
cin >> n >> l;
map<int, int> nn;
vector<int> nums(n);
vector<vector<int>> ns(n+1);
int d=0;
for (int i = 0; i < n; i++)
{
int a;
cin >> a;
if (nn[a]==0) nn[a] = ++d;
nums[i] = nn[a];
ns[nn[a]].push_back(i);
}
int q;
cin >> q;
vector<int> qs(q);
vector<vector<int>> ans(q, vector<int>(n-l+1, 0));
for (int i = 0; i < q; i++) cin >> qs[i];
vector<int> inter(2*n, 0);
vector<int> qqs(n+1, 0);
qqs[0] = n-l+1;
int r = 0;
for (int i = 0; i <= n-l; i++)
{
if (i)
{
for (int ele:ns[nums[i-1]])
{
if (ele+l-min(i-1, l-1)>n) continue;
if (ele-min(i-1, l-1)<0) continue;
qqs[inter[ele-i+1+n]]--;
inter[ele-i+1+n]--;
}
}
while (r-i < l)
{
for (int ele:ns[nums[r]])
{
if (ele+l-(r-i)>n) continue;
if (ele-(r-i)<0) continue;
inter[ele-r+n]++;
qqs[inter[ele-r+n]]++;
}
r++;
}
for (int j = 0; j < q; j++)
{
ans[j][i] = qqs[l-qs[j]]-1;
}
}
for (auto ele:ans)
{
for (int ele2:ele) cout << ele2 << " ";
cout << "\n";
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
202 ms |
860 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
202 ms |
860 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |