CCHOCOLATES-Editorial

PROBLEM LINK:

Contest Division 1
Contest Division 2
Contest Division 3
Contest Division 4

Setter: Mradul Bhatnagar
Tester: Abhinav Sharma, Lavish Gupta
Editorialist: Devendra Singh

DIFFICULTY:

405

PREREQUISITES:

None

PROBLEM:

Chef has X 5 rupee coins and Y 10 rupee coins. Chef goes to a shop to buy chocolates for Chefina where each chocolate costs Z rupees. Find the maximum number of chocolates that Chef can buy for Chefina.

EXPLANATION:

Total money that Chef has is X\cdot 5+10\cdot Y rupees. Each chocolate costs Z rupees.
There the maximum number of chocolates that Chef can buy for Chefina is floor(\frac{X\cdot 5+Y\cdot 10}{Z})

TIME COMPLEXITY:

O(1) for each test case.

SOLUTION:

Editorialist's solution
#include "bits/stdc++.h"
using namespace std;
#define ll long long
#define pb push_back
#define all(_obj) _obj.begin(), _obj.end()
#define F first
#define S second
#define pll pair<ll, ll>
#define vll vector<ll>
ll INF = 1e18;
const int N = 1e5 + 11, mod = 1e9 + 7;
ll max(ll a, ll b) { return ((a > b) ? a : b); }
ll min(ll a, ll b) { return ((a > b) ? b : a); }
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void sol(void)
{
    int x, y, z;
    cin >> x >> y >> z;
    cout << ((x * 5 + y * 10) / z) << '\n';
    return;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
    int test = 1;
    cin >> test;
    while (test--)
        sol();
}

thank you