Codechef Problems: Entertainments (ENTERTAIN)
Problem Statement:
https://www.codechef.com/problems/ENTERTAIN
Solution:
Given, N : number of children
200:
cost of a toy
1000:
cost of television
Condition: chef can buy one television for all children to
watch or can buy a toy for each child
To find : minimum cost of chef to pay for entertainment
Condition 1 : cost of toys is less than cost of television
(i.e., 200 * N <= 1000)
Output : 200 * N
Condition 2: otherwise
Output: 1000
Code Solution:
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
if (n * 200 <=
1000) {
cout <<
n * 200 << endl;
} else {
cout <<
1000 << endl;
}
return 0;
}
Comments
Post a Comment