467

#include <iostream>
#include <cstdio>
#include <sstream>
#include <string>
#include <cstring>
#include <algorithm>

using namespace std;
int signal[4000];
int main()
{
	string str;
	int kase=1;
	stringstream ss;
	int a,b,c,mx;
	int arr[12];

	while(getline(cin,str))
	{
		ss.clear();
		ss<<str;
		int k=1;
		int time=0;
		while(ss>>arr[k])k++;
		sort(arr+1,arr+k);

		memset(signal,0,sizeof(signal));
		for(int i=1;i<k;i++)
		{
			for(int j=0;j<3601;)
			{
				a=arr[i]-5;
				b=5;
				c=arr[i];
				while(a--)signal[j++]++;
				while(b--)signal[j++]=0;
				while(c--)signal[j++]=0;
			}
		}
		for(int i=arr[1];i<=3600;i++)
		{
			if(signal[i]==k-1)
			{
				time=i;
				break;
			}
		}
		if(!time)
		cout<<"Set "<<kase++<<" is unable to synch after one hour.\n";
		else
		cout<<"Set "<<kase++<<" synchs again at "<<time/60<<" minute(s) and "<<time%60<<" second(s) after all turning green.\n";
	}
	return 0;
}

 

Leave a Reply

Your email address will not be published. Required fields are marked *