Submission
Status:
[-S][-S][P][-][P][P][P][P][P][P]
Score: 70
User: akuyga1
Problemset: โรงงานหุ่นยนต์
Language: cpp
Time: 0.002 second
Submitted On: 2025-02-26 10:47:23
#include "bits/stdc++.h"
using namespace std;
#define ii pair<int,int>
#define f first
#define s second
#define mp make_pair
int A,B,C,D;
int N,K;
int M=0;
void construct(vector<int> x){
int n=N,k=K,a=A,b=B,c=C,d=D;
int m=0;
for(auto i:x){
if(i==1){
//white whole
int temp=min(a,n);
temp=min(temp,c);
m+=temp;
a-=temp;
n-=temp;
c-=temp;
}
else if(i==2){
//black whole
int temp=min(b,n);
temp=min(temp,d);
m+=temp;
b-=temp;
n-=temp;
d-=temp;
}
else if(i==3){
//white head
int temp=min(a,k);
temp=min(temp,d);
m+=temp;
a-=temp;
k-=temp;
d-=temp;
}
else if(i==4){
//black head
int temp=min(b,k);
temp=min(temp,c);
m+=temp;
b-=temp;
k-=temp;
c-=temp;
}
}
M=max(m,M);
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin>>A>>B>>C>>D;
cin>>N>>K;
//4! possibile ways using for prioritizing robot
vector<int> way(4);
for(int i=0;i<4;i++)
for(int j=0;j<4;j++)
for(int k=0;k<4;k++)
for(int l=0;l<4;l++)
if(i!=j&&i!=k&&i!=l&&j!=k&&j!=l&&k!=l)
{
way[i]=1; way[j]=2; way[k]=3; way[l]=4;
construct(way);
}
cout<<M;
}