My Bad Code
I wrote this code for codechef march 2021 contest for "college life 4" problem but was unsucessfull to solve it
Link of the problem hereThis is for the futute me. Try to solve this problem if you think you are smart
import java.util.*;
import java.util.stream.*;
import java.io.*;
class multiMap
{
long key;
long value;
multiMap(long key,long value){
this.key = key;
this.value = value;
}
void display(){
System.out.println("key : "+key+"\t value : "+value);
}
}
class MyList{
List keyMapList = new ArrayList<>();
public MyList(long a , long b,long c,long A,long B,long C){
keyMapList.add(new multiMap(a,A));
keyMapList.add(new multiMap(b,B));
keyMapList.add(new multiMap(c,C));
keyMapList = keyMapList.stream().sorted(Comparator.comparing(e->e.key)).collect(Collectors.toList());
}
void pop(){
keyMapList.remove(0);
}
long getValue(long index){
return keyMapList.get((int)index).value;
}
long getKey(){
return keyMapList.get(0).key;
}
void display(){
keyMapList.forEach(e -> System.out.println("key : "+e.key+"\t value : "+e.value));
}
}
class cf
{
static void solve(long n,long e,long h,long a , long b,long c){
long A = (e/2)>n?n:e/2;
long B = (h/3)>n?n:h/3;
long C = Math.min(e,h)>n?n:Math.min(e,h);
// System.out.println("A:"+A+" B:"+B+" C:"+C);
long remE = e%2;
long remH = h%3;
if((A+B+Math.min(remE,remH))0){
if(list.getValue(0)!=0)
{
ans += list.getKey()*Math.min(n,list.getValue(0));
n -= list.getValue(0);
// System.out.println("ans : "+ans+" and n :"+n);
if(n<0)
break;
}
list.pop();
}
System.out.println(ans);
}
static Scanner input = new Scanner(System.in);
// static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
public static void main(String[] args) {
try
{
int t = input.nextInt();
while(t-->0){
long n = input.nextLong();
long e = input.nextLong();
long h = input.nextLong();
long a = input.nextLong();
long b = input.nextLong();
long c = input.nextLong();
// System.out.println(calc(n,e,h,a,b,c));
// String arrr[] = br.readLine().split("\\s+");
// long n = Long.parseLong(arrr[0]);
// long e = Long.parseLong(arrr[1]);
// long h = Long.parseLong(arrr[2]);
// long a = Long.parseLong(arrr[3]);
// long b = Long.parseLong(arrr[4]);
// long c = Long.parseLong(arrr[5]);
solve(n,e,h,a,b,c);
}
}
catch(Exception e){
return;
}
}
}