/// Raihan Ruhin /// CSE, Jahangirnagar University. /// Dhaka-Bangladesh. /// id: raihanruhin (topcoder / codeforces / codechef / uva / uvalive / spoj), 3235 (lightoj) /// mail: raihanruhin@ (yahoo / gmail / facebook) /// blog: ruhinraihan.blogspot.com #include<bits/stdc++.h> using namespace std; #define SET(a) memset(a,-1,sizeof(a)) #define CLR(a) memset(a,0,sizeof(a)) #define PI acos(-1.0) #define MOD 1000000007 #define MX 100000 int main() { //ios_base::sync_with_stdio(0);cin.tie(0); int tc, kk=1, n, girl[5], boy[5]; while(cin>>girl[0]>>girl[1]>>girl[2]>>boy[0]>>boy[1]) { if(girl[0]==0) break; sort(girl, girl+3); sort(boy, boy+2); if(boy[1]>girl[2] && boy[0]>girl[2]) { int lowest = 1; while(boy[0]==lowest || boy[1]==lowest || girl[0]==lowest || girl[1]==lowest || girl[2]==lowest) lowest++; if(lowest>52) lowest=-1; cout<<lowest<<"\n"; } else if(boy[1]>girl[2]) { int lowest; if(boy[0]<girl[1]) lowest = girl[2]+1; else lowest = girl[1]+1; while(boy[0]==lowest || boy[1]==lowest || girl[0]==lowest || girl[1]==lowest || girl[2]==lowest) lowest++; if(lowest>52) lowest=-1; cout<<lowest<<"\n"; } else if(boy[0]>girl[1]) { int lowest = girl[1]+1; while(boy[0]==lowest || boy[1]==lowest || girl[0]==lowest || girl[1]==lowest || girl[2]==lowest) lowest++; if(lowest>52) lowest=-1; cout<<lowest<<"\n"; } else cout<<"-1\n"; } return 0; }
Wednesday, 20 January 2016
Jollo (UVA 12247, UVALive 4814, Regionals 2010 >> Latin America)
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment