1774B - Coloring - CodeForces Solution


constructive algorithms greedy math *1500

Please click on ads to support us..

C++ Code:

#include<bits/stdc++.h>
using namespace std;
 
int main()
{
	int t,n,m,k;
	cin>>t;
	while(t--)
	{
		cin>>n>>m>>k;
		int res=0;
		for(int i=1;i<=m;i++)
		{
			int a;
			cin>>a;
			if(a==(n+k-1)/k)
			res++;
			if(a>(n+k-1)/k)
			res=1 << 30;
		}
		puts(res<=(n-1)%k+1? "YES" : "NO");
	}
	
}


Comments

Submit
0 Comments
More Questions

Count of integers
Differences of the permutations
Doctor's Secret
Back to School
I am Easy
Teddy and Tweety
Partitioning binary strings
Special sets
Smallest chosen word
Going to office
Color the boxes
Missing numbers
Maximum sum
13 Reasons Why
Friend's Relationship
Health of a person
Divisibility
A. Movement
Numbers in a matrix
Sequences
Split houses
Divisible
Three primes
Coprimes
Cost of balloons
One String No Trouble
Help Jarvis!
Lift queries
Goki and his breakup
Ali and Helping innocent people