#include <bits/stdc++.h>
#include "paint.h"
//#define int long long
#define ff first
#define ss second
#define pb push_back
#define all(x) x.begin(),x.end()
using namespace std;
int minimumInstructions(int N, int M, int K,vector<int> C,vector<int> A, vector<vector<int>> B) {
for(int i=0;i<M;i++){
sort(all(B[i]));
}
int ans=0;
vector <int> used(N);
for(int i=0;i<=N-M;i++){
if(!used[i]){
for(int y=i;y>=max(0,i-M+1);y--){
bool ok=0;
for(int x=0;x<M;x++){
int cnt=0;
for(int l=0;l<M;l++){
int pos=(x+l)%M;
auto it=lower_bound(all(B[pos]),C[y+l]);
if(it!=B[pos].end() && *it==C[y+l])cnt++;
else break;
}
if(cnt==M)ok=1;
}
if(ok){
for(int j=y;j<y+M;j++)used[j]=1;
ans++;
break;
}
}
if(!used[i]){
ans=-1;break;
}
}
}
for(int i=0;i<N;i++){
if(!used[i])ans=-1;
}
return ans;
}
/*signed main(){
ios_base::sync_with_stdio();
cin.tie(0);cout.tie(0);
int n,m,k;
cin>>n>>m>>k;
vector <int> c(n),a(m);
for(int i=0;i<n;i++)cin>>c[i];
for(int i=0;i<m;i++)cin>>a[i];
vector <vector <int> > b(m);
for(int i=0;i<m;i++){
for(int j=0;j<a[i];j++){
int x;
cin>>x;
b[i].pb(x);
}
}
cout<<minimumInstructions(n,m,k,c,a,b)<<"\n";
}*/
/*
8 3 5
3 3 1 3 4 4 2 2
3 2 2
0 1 2
2 3
3 4
5 4 4
1 0 1 2 2
2 1 1 1
0 1
1
2
3
*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
500 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
500 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
500 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
500 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
500 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |