#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> ii;
#define REP(i, n) for(int i = 0;i < n;i ++)
#define REP1(i, n) for(int i = 1;i <= n;i ++)
#define FILL(i, n) memset(i, n, sizeof(i))
#define X first
#define Y second
#define pb push_back
#define SZ(_a) ((int)(_a).size())
#define ALL(_a) (_a).begin(), (_a).end()
#ifdef brian
#define IOS()
template<typename T>void _do(T &&x){cerr<<x<<endl;}
template<typename T, typename ...t> void _do(T &&x, t &&...X){cerr<<x<<", ";_do(X...);}
#define debug(...) {\
fprintf(stderr, "%s - %d (%s) = ", __PRETTY_FUNCTION__, __LINE__, #__VA_ARGS__);\
_do(__VA_ARGS__);\
}
#else
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#define debug(...)
#define endl '\n'
#endif
const ll MAXn = 2e3 + 5;
const ll INF = ll(1e17);
const ll MOD = 1000000007;
const ll bs = 880301;
int dt[MAXn][MAXn];
int d[MAXn], a[MAXn];
int main(){
IOS();
ll n, l;
cin>>n>>l;
REP1(i, n)cin>>d[i];
REP1(i, n)REP1(j, n)if(i + j <= n)dt[i][j] = (d[j] != d[j + i]);
REP1(i, n)REP1(j, n)dt[i][j] += dt[i][j - 1];
ll q;
cin>>q;
while(q--)
{
ll k;
cin>>k;
REP1(i, n)a[i] = 0;
REP1(i, n - l + 1)for(int j = i + 1;j <= n - l + 1;j ++)if(dt[j - i][i + l - 1] - dt[j - i][i - 1] <= k)a[i] ++, a[j]++;
REP1(i, n - l + 1)cout<<a[i]<<" ";
cout<<endl;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
760 KB |
Output is correct |
3 |
Correct |
3 ms |
760 KB |
Output is correct |
4 |
Correct |
2 ms |
760 KB |
Output is correct |
5 |
Correct |
2 ms |
760 KB |
Output is correct |
6 |
Correct |
2 ms |
760 KB |
Output is correct |
7 |
Correct |
2 ms |
760 KB |
Output is correct |
8 |
Correct |
4 ms |
1912 KB |
Output is correct |
9 |
Correct |
4 ms |
1916 KB |
Output is correct |
10 |
Correct |
5 ms |
1912 KB |
Output is correct |
11 |
Correct |
5 ms |
1912 KB |
Output is correct |
12 |
Correct |
5 ms |
1912 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
760 KB |
Output is correct |
3 |
Correct |
3 ms |
760 KB |
Output is correct |
4 |
Correct |
2 ms |
760 KB |
Output is correct |
5 |
Correct |
2 ms |
760 KB |
Output is correct |
6 |
Correct |
2 ms |
760 KB |
Output is correct |
7 |
Correct |
2 ms |
760 KB |
Output is correct |
8 |
Correct |
4 ms |
1912 KB |
Output is correct |
9 |
Correct |
4 ms |
1916 KB |
Output is correct |
10 |
Correct |
5 ms |
1912 KB |
Output is correct |
11 |
Correct |
5 ms |
1912 KB |
Output is correct |
12 |
Correct |
5 ms |
1912 KB |
Output is correct |
13 |
Correct |
86 ms |
16152 KB |
Output is correct |
14 |
Correct |
111 ms |
16164 KB |
Output is correct |
15 |
Correct |
76 ms |
16120 KB |
Output is correct |
16 |
Correct |
192 ms |
16248 KB |
Output is correct |
17 |
Correct |
172 ms |
16296 KB |
Output is correct |
18 |
Correct |
220 ms |
16168 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
67 ms |
32376 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
67 ms |
32376 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
760 KB |
Output is correct |
3 |
Correct |
3 ms |
760 KB |
Output is correct |
4 |
Correct |
2 ms |
760 KB |
Output is correct |
5 |
Correct |
2 ms |
760 KB |
Output is correct |
6 |
Correct |
2 ms |
760 KB |
Output is correct |
7 |
Correct |
2 ms |
760 KB |
Output is correct |
8 |
Correct |
4 ms |
1912 KB |
Output is correct |
9 |
Correct |
4 ms |
1916 KB |
Output is correct |
10 |
Correct |
5 ms |
1912 KB |
Output is correct |
11 |
Correct |
5 ms |
1912 KB |
Output is correct |
12 |
Correct |
5 ms |
1912 KB |
Output is correct |
13 |
Correct |
86 ms |
16152 KB |
Output is correct |
14 |
Correct |
111 ms |
16164 KB |
Output is correct |
15 |
Correct |
76 ms |
16120 KB |
Output is correct |
16 |
Correct |
192 ms |
16248 KB |
Output is correct |
17 |
Correct |
172 ms |
16296 KB |
Output is correct |
18 |
Correct |
220 ms |
16168 KB |
Output is correct |
19 |
Runtime error |
67 ms |
32376 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
20 |
Halted |
0 ms |
0 KB |
- |