#include "paint.h"
#include<bits/stdc++.h>
using namespace std;
#define lli int
#define rep(i,a,b) for (int i = (a); i <= (b); i++)
#define repa(i,a,b) for (int i = (a); i >= (b); i--)
#define debug(a) cout << #a << " = " << a << endl
#define debugsl(a) cout << #a << " = " << a << ", "
#define MAX 20000
#define MK 100000
lli n,m,k,res,pos,mejor,dif,a,last;
//valores de 0 a m
map<int, int> lejos[MAX+2];
bitset<MK> tabla[2002];
vector<int> contratistas[MK];
lli top[MAX+2];
//checar memoria
int minimumInstructions(int N, int M, int K, std::vector<int> C,std::vector<int> A, std::vector<std::vector<int>> B) {
n = N;
m = M;
k = K;
rep(i,0,m-1) {
rep(j,0,A[i]-1) {
contratistas[B[i][j]].push_back(i);
}
}
repa(i,n-1,0) {
top[i] = 0;
for(auto cont : contratistas[C[i]]) {
int v = (lejos[i+1].count((cont + 1)%m)) ? lejos[i+1][(cont+1)%m] + 1 : 1;
lejos[i][cont] = min(m, v);
top[i] = max(top[i], v);
}
}
if (top[0] < m) return -1;
pos = m;
last = 0;
res = 1;
rep(i,1,n-1) {
if (top[i] == m) last = i;
if (i == pos) {
pos = last + m;
res++;
}
}
if (pos < n) return -1;
else return res;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
3540 KB |
Output is correct |
2 |
Correct |
2 ms |
3540 KB |
Output is correct |
3 |
Correct |
2 ms |
3600 KB |
Output is correct |
4 |
Correct |
2 ms |
3540 KB |
Output is correct |
5 |
Correct |
2 ms |
3540 KB |
Output is correct |
6 |
Correct |
2 ms |
3540 KB |
Output is correct |
7 |
Incorrect |
3 ms |
3540 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
3540 KB |
Output is correct |
2 |
Correct |
2 ms |
3540 KB |
Output is correct |
3 |
Correct |
2 ms |
3600 KB |
Output is correct |
4 |
Correct |
2 ms |
3540 KB |
Output is correct |
5 |
Correct |
2 ms |
3540 KB |
Output is correct |
6 |
Correct |
2 ms |
3540 KB |
Output is correct |
7 |
Incorrect |
3 ms |
3540 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
3540 KB |
Output is correct |
2 |
Correct |
2 ms |
3540 KB |
Output is correct |
3 |
Correct |
2 ms |
3600 KB |
Output is correct |
4 |
Correct |
2 ms |
3540 KB |
Output is correct |
5 |
Correct |
2 ms |
3540 KB |
Output is correct |
6 |
Correct |
2 ms |
3540 KB |
Output is correct |
7 |
Incorrect |
3 ms |
3540 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
3540 KB |
Output is correct |
2 |
Correct |
2 ms |
3540 KB |
Output is correct |
3 |
Correct |
2 ms |
3600 KB |
Output is correct |
4 |
Correct |
2 ms |
3540 KB |
Output is correct |
5 |
Correct |
2 ms |
3540 KB |
Output is correct |
6 |
Correct |
2 ms |
3540 KB |
Output is correct |
7 |
Incorrect |
3 ms |
3540 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
3540 KB |
Output is correct |
2 |
Correct |
2 ms |
3540 KB |
Output is correct |
3 |
Correct |
2 ms |
3600 KB |
Output is correct |
4 |
Correct |
2 ms |
3540 KB |
Output is correct |
5 |
Correct |
2 ms |
3540 KB |
Output is correct |
6 |
Correct |
2 ms |
3540 KB |
Output is correct |
7 |
Incorrect |
3 ms |
3540 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |