Janmansh at Fruit Market Solution || Codechef March Cook-Off 2022

        

Janmansh at Fruit Market Solution 

Codechef March Cook-Off 2022
Problem Code : JMARKET

Solution :

#include <bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
using namespace std;

void solve()
{
    ll x, a[3];
    cin >> x >> a[0] >> a[1] >> a[2];
    sort(a, a + 3);
    cout << (x - 1) * a[0] + a[1] << "\n";
}

int main()
{
    ll t;
    cin >> t;
    while (t--)
    {
        solve();
    }
}

Comments