Workers
Question :-
https://www.codechef.com/problems/CHEFWORK
Solution in C++ language :-
#include <iostream>
using namespace std;
int main() {
// your code goes here
int n,i;
cin>>n;
int c[n],t[n];
for(i=0;i<n;i++)
cin>>c[i];
for(i=0;i<n;i++)
cin>>t[i];
int a=100000,b=100000,d=100000;
for(i=0;i<n;i++){
if(t[i]==3){
if(c[i]<a)
a=c[i];
}
else if(t[i]==2){
if(c[i]<b)
b=c[i];
}
else if(t[i]==1){
if(c[i]<d)
d=c[i];
}
}
if(a>b+d)
cout<<b+d;
else
cout<<a;
return 0;
}
Comments
Post a Comment