https://i2.wp.com/eblogarithm.com/wp-content/uploads/2017/01/Codeforces-Round-386-Div-2-problem-D-Green-and-Black-Tea-Solution-in-CC1.png?fit=640%2C360

Codeforces Round #386 (Div. 2), problem: (D) Green and Black Tea Solution in C/C++

Codeforces Round #386 (Div. 2), problem: (D) Green and Black Tea Solution in C/C++

 

 

#include<stdio.h>
int main()
{
    long long n,k,a,b,i;
	char x='G',y='B';
	int num=0;
	scanf("%I64d%I64d%I64d%I64d",&n,&k,&a,&b);
	if(a>b)
	{
		int t=a;a=b;b=t;
		char z=x;x=y;y=z;
	}
	if(b>(a+1)*(k)) {
		printf("NO\n");
		return 0;
	}
	for(i=0;i<n;i++){
		if(b>a&&num<k){printf("%c",y);b--;num++;}
		else {printf("%c",x);a--;num=0;}
	}
	return 0;
}
(Visited 112 times, 1 visits today)



There are no comments

Add yours

Leave a Reply

%d bloggers like this: