1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
#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; } |