167712025-05-12 20:31:52tomi7Négyzetrács festéscpp17Wrong answer 0/1001.1s14396 KiB
// Source: https://usaco.guide/general/io

#include <bits/stdc++.h>
using namespace std;

int main() {
	int m, n;cin>>m>>n;
    vector<int> a(n+m-1);
    vector<int> c(n+m-1);
    for(int i=0;i<n+m-1;i++){
        cin>>a[i];
    }
    for(int i=0;i<n+m-1;i++){
        cin>>c[i];
    }
    int vegans=INT_MAX;
    for(int i=0;i<(1<<n+m-1);i++){
//        cout<<"Happy"<<endl;
        int ans=0;
        vector<int> visit(n+m-1, false);
        vector<int> vis(n+m-1, false);
        for(int j=0;j<n+m-1;j++){
//            cout<<"Happyhappy "<<__LINE__ <<endl;
            if((i>>j) & 1){
                vis[j]=true;
                ans+=a[j];
            }
        }
//        cout<<"Happyhappyhappy"<<endl;
        for(int j=0;j<n;j++){
  //          cout<<"Happy4"<<endl;
            for(int h=0;h<m;h++){
  //              cout<<"Happynagyonhappy"<<endl;
                if(!vis[h-j+n-1] && !visit[h+j]){
                    visit[h+j]=true;
                    ans+=c[h+j];
                }
            }
        }
        vegans=min(vegans, ans);
    }
    cout<<vegans<<'\n';
}
SubtaskSumTestVerdictTimeMemory
subtask10/10
1Accepted1ms316 KiB
2Accepted1ms316 KiB
3Wrong answer1ms316 KiB
4Wrong answer1ms316 KiB
5Wrong answer1ms316 KiB
6Wrong answer1ms316 KiB
7Wrong answer1ms316 KiB
8Wrong answer1ms564 KiB
9Wrong answer1ms316 KiB
subtask20/10
1Wrong answer243ms316 KiB
2Wrong answer8ms508 KiB
3Wrong answer1ms500 KiB
4Wrong answer2ms316 KiB
5Wrong answer1ms316 KiB
6Wrong answer243ms508 KiB
7Wrong answer4ms404 KiB
8Wrong answer243ms508 KiB
9Wrong answer116ms316 KiB
subtask30/10
1Wrong answer1ms508 KiB
2Time limit exceeded1.085s316 KiB
3Wrong answer712ms400 KiB
4Wrong answer1ms512 KiB
5Time limit exceeded1.1s316 KiB
6Wrong answer1ms316 KiB
7Wrong answer1ms336 KiB
8Time limit exceeded1.1s316 KiB
9Time limit exceeded1.085s316 KiB
10Time limit exceeded1.087s316 KiB
subtask40/20
1Wrong answer4ms512 KiB
2Wrong answer4ms316 KiB
3Time limit exceeded1.08s508 KiB
4Time limit exceeded1.08s316 KiB
5Time limit exceeded1.1s484 KiB
6Wrong answer428ms316 KiB
7Time limit exceeded1.087s316 KiB
8Time limit exceeded1.085s316 KiB
9Time limit exceeded1.088s332 KiB
10Wrong answer8ms316 KiB
11Time limit exceeded1.1s316 KiB
12Time limit exceeded1.072s316 KiB
13Time limit exceeded1.075s760 KiB
subtask50/10
1Wrong answer190ms7220 KiB
2Wrong answer188ms7224 KiB
3Wrong answer189ms7220 KiB
4Wrong answer200ms7476 KiB
5Wrong answer206ms7732 KiB
6Wrong answer168ms5172 KiB
7Accepted1ms316 KiB
subtask60/20
1Wrong answer407ms12080 KiB
2Time limit exceeded1.082s14396 KiB
3Wrong answer372ms11080 KiB
4Wrong answer384ms11572 KiB
5Wrong answer382ms11568 KiB
6Wrong answer277ms8756 KiB
7Wrong answer360ms10700 KiB
subtask70/20
1Wrong answer172ms6728 KiB
2Wrong answer186ms7036 KiB
3Wrong answer233ms7400 KiB
4Wrong answer239ms6092 KiB
5Time limit exceeded1.082s7460 KiB
6Time limit exceeded1.1s7412 KiB
7Time limit exceeded1.088s6096 KiB
8Time limit exceeded1.1s7408 KiB
9Time limit exceeded1.085s7436 KiB
10Time limit exceeded1.1s7732 KiB
11Time limit exceeded1.082s8496 KiB
12Time limit exceeded1.1s9268 KiB
13Time limit exceeded1.085s11572 KiB
14Time limit exceeded1.1s13364 KiB