/// 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 100010 int main() { ios_base::sync_with_stdio(0);cin.tie(0); int tc, kk=1, n, t1, t2, t3, s, p, x, y, person[12]; char ch; while(cin>>p>>s && p) { cin>>t1>>t2>>t3; cin>>n; CLR(person); bool lock[12]={false}; int turn=0; for(int i=0;i<n;i++) { cin>>x>>y; person[turn]+=x+y; if(person[turn]==t1 || person[turn]==t2 || person[turn]==t3) lock[turn]=true; turn=(turn+1)%p; while(lock[turn]) { lock[turn]=false; turn=(turn+1)%p; } } for(int i=0;i<p;i++) if(person[i]>s) { cout<<i+1<<"\n"; break; } //cout<< <<"\n"; } return 0; }
Wednesday, 23 September 2015
Dice (UVALive - 2881, Regionals 2003 >> Latin America - South America)
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment