#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pii pair<int,int>
#define fi first
#define se second
const int INF=1000000000;
int minimumInstructions(int n,int m,int k,vector<int> c,vector<int> a,vector<vector<int>> b){
vector<int> contractors[k];
for(int i=0;i<m;i++){
for(auto j:b[i]){
contractors[j].push_back(i);
}
}
vector<int> choices[n];
for(int i=0;i<n;i++){
for(int j:contractors[c[i]]){
choices[i].push_back((j+n-1-i)%m);
}
}
bool valid[n]={};
int cnt[m]={};
for(int i=0;i<m;i++) for(int j:choices[i]){
cnt[j]++;
if(cnt[j]==m) valid[0]=true;
}
for(int i=1;i<=n-m;i++){
for(int j:choices[i-1]){
cnt[j]--;
}
for(int j:choices[i+m-1]){
cnt[j]++;
if(cnt[j]==m) valid[i]=true;
}
}
if(!valid[n-m]) return -1;
int ind=n-m;
int lvi=n-m;
int ans=0;
for(int i=n-m;i>=0;i--){
if(valid[i]) lvi=i;
if(i==ind-m){
if(lvi==ind) return -1;
ind=lvi;
ans++;
}
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |