Time To Play Editorial

Question Link

Author: Suryakant Pandey , Apurv Gupta
Tester: Suryakant Pandey , Apurv Gupta
Editorialist: Suryakant Pandey

DIFFICULTY:

EASY

PROBLEM:

we have to find alarm time from the given time after max( 0 , x-5) minutes

EXPLANATION:

So according to the question we have to add max( 0, x-5) minutes to the current time to get the alarm time.
we will first check if x is more than 5 if not then we will just print the current time and return else
we will simply add x-5 to the minutes .
then we will simply add the m/60 to the hours count and after that simply take mod 24 for hours count and mod 60 for minutes count and print the answer .
Don’t forget to use fast input output and “\n” if you are using C++.

SOLUTIONS:

#include <iostream>
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int n;
	cin>>n;
	for (int i=0;i<n;i++)
	{
	    int h,m,x;
	    cin>>h>>m>>x;
	    if (x<=5)
	        cout<<h<<" "<<m<<"\n";
	    else
	    {
	        x=x-5;
	        m+=x;
	        h+=m/60;
	        m=m%60;
	        h=h%24;
            cout<<h<<" "<<m<<"\n";
	        
	    }
	}
	return 0;
}