Control the Pollution Solution || Codechef Starters - 26

     

Control the Pollution Solution 

Codechef Starters - 26
Problem Code : SMOKE

Solution :

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

void solve()
{
    ll n, x, y;
    cin >> n >> x >> y;
    ll ans = 0;
    if (n >= 100)
    {
        ans += (n / 100) * min(25 * y, x);
        n -= (n / 100) * 100;
    }
    ll car;
    if (n % 4 == 0)
    {
        car = n / 4;
    }
    else
    {
        car = (n / 4) + 1;
    }
    ans += min(x, car * y);
    cout << ans << "\n";
}

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

Comments