Tag: problem: (C) Voting Solution in C/C++

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

Codeforces Round #388 (Div. 2), problem: (C) Voting Solution in C/C++ #include<stdio.h> typedef unsigned u; char S,D; 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=='D')++ds; if(S=='R')++rs; } for(;ds&&rs;) { for(i=-1;++i<l;)if(!D) { if(S=='D') { if(dq){--dq;--ds;D=1;continue;} ++rq; } if(S=='R') { if(rq){--rq;--rs;D=1;continue;} ++dq; } } } if(ds)putchar('D'); if(rs)putchar('R'); return 0; }

Want to stay up to date with the latest news?

We would love to hear from you! Please fill in your details and we will stay in touch. It's that simple!