# To Do List - Editorial

Problem link: CodeChef: Practical coding for everyone

Author and Editorialist: ramola_singh

DIFFICULTY:
Cakewalk

PREREQUISITES:
None

PROBLEM:
It’s 10:30 pm and Khushi is trying to make a to-do list for the next day.
There are ‘N’ no of tasks where each requires ‘H’ hours to complete.Considering she takes ‘X’ hours in completing her mundane tasks, determine whether she will be able to finish all the tasks the other day.

QUICK EXPLANATION:
She can complete the task(s) if ( X + Hi ) <= 24 (hours), where Hi is the time taken for each task.

EXPLANATION:
There are 24 hours in a day. Out of which, she has to give X hours to mundane activities.
That is, the total time for completing all tasks will be calculated as X+Hi .
If the total time consumed is either 24 or less, it means she had enough time, print ‘YES’. In case it exceeds 24, then print ‘NO’.

SOLUTION:

Editorialist's Solution
``````#include<iostream>

using namespace std;

int main() {
int N,X,H[24],totalTime=0;
cin>>N>>X;
totalTime+=X;
for(int i=0;i<N;i++){
cin>>H[i];
totalTime+=H[i];
}
string ans=( (totalTime<=24) ? "YES" : "NO");
cout<<ans;
return 0;
}
``````
5 Likes