#include<bits/stdc++.h>
using namespace std;
int arr1[1000000], arr2[1000000], arr[101][101];
int main(){
int n, m;
cin>>n>>m;
for(int i=0; i<n+m-1; i++)
cin>>arr1[i];
for(int i=0; i<n+m-1; i++)
cin>>arr2[i];
int hi=m+n-1, mini=2e9;
for(int i=0; i<(1<<hi); i++){
for(int a=0; a<n; a++)
for(int b=0; b<m; b++)
arr[a][b]=0;
int tot=0;
for(int j=0; j<hi; j++){
if(i&(1<<j)){
for(int k=0; k<n; k++)
if(j-k>=0 && j-k<m)
arr[k][j-k]=1;
tot+=arr2[j];
}
}
set<int> si;
for(int j=0; j<n; j++){
for(int k=0; k<m; k++){
if(arr[j][k]==0)
si.insert(j-k+n-2);
}
}
for(auto x:si)
tot+=arr1[x];
mini=min(mini, tot);
}
cout<<mini;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
512 KB |
Output is correct |
3 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
512 KB |
Output is correct |
3 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
512 KB |
Output is correct |
3 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
512 KB |
Output is correct |
3 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
377 ms |
11384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
729 ms |
3572 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
512 KB |
Output is correct |
3 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |