Untitled

 avatar
unknown
plain_text
4 years ago
553 B
4
Indexable
#include <bits/stdc++.h>
using namespace std;

int main() {
	// your code goes here
	int t;
	cin>>t;
	while(t--){
	    int H,M,X;
	    cin>>H>>M>>X;
	    if(X>5){
	        int h=X/60,m=X%60;
	    
    	    H += h;
    	    M += m;
    	    
    	    if(M>59){
    	        H+=M/60;
    	        M=M%60;
    	    }
    	    if(H>23){
    	        H=H-24;
    	    }
    	    
    	    
    	    if(M<5){
    	        H--;
    	        M=60-(5-M);
    	    }
    	    else{
    	        M-=5;
    	    }
	    }
	    cout<<H<<" "<<M<<endl;
	}
	return 0;
}
Editor is loading...