Codeforces Round #388 (Div. 2), problem: (C) Voting Solution in C/C++

By |2017-04-07T22:11:45+00:00January 6th, 2017|Categories: C/C++, Programming|Tags: , , , , , , , |

Codeforces Round #388 (Div. 2), problem: (C) Voting Solution in C/C++   #include<stdio.h> typedef unsigned u; char S[222222],D[222222]; int main() { u l,i,ds,rs,dq,rq; ds=rs=dq=rq=0; scanf("%u%s",&l,S); for(i=-1;++i<l;) { if(S[i]=='D')++ds; if(S[i]=='R')++rs; } for(;ds&&rs;) { for(i=-1;++i<l;)if(!D[i]) { if(S[i]=='D') { if(dq){--dq;--ds;D[i]=1;continue;} ++rq; } if(S[i]=='R') { if(rq){--rq;--rs;D[i]=1;continue;} ++dq; } [...]