Codechef Problems: Playing with Toys (TOYS)

 Problem Statement:

https://www.codechef.com/problems/TOYS


Solution:

Given, N : toys chef got on his birthday

                M : days after his birthday

Condition – chef breaks 1 toy every day

To find: number of remaining toys chef has

Condition 1 : N > M (chef had more toys on his birthday than the days passed after his birthday)

Output: N – M

Condition 2 : Otherwise

Output: 0


Code Solution:

#include <bits/stdc++.h>

using namespace std;

int main() {

    int n, m;

    cin >> n >> m;

    if (n > m) {

        cout << n - m << endl;

    } else {

        cout << 0 << endl;

    }

    return 0;

}

Comments