# Bowling Strategy Codechef Solution

Bowling Strategy Codechef Solution: Hello coders, today we are going to solve Bowling Strategy Codechef Solution.

## Problem

In a cricket game, an over is a set of six valid deliveries of balls performed by one player ― the bowler for this over.

Consider a cricket game with a series of NN overs (numbered 11 through NN) played by KK players (numbered 11 through KK). Each player may be the bowler for at most LL overs in total, but the same player may not be the bowler for any two consecutive overs. Assign exactly one bowler to each over in such a way that these rules are satisfied or determine that no such assignment exists.

### Input

• The first line of the input contains a single integer TT denoting the number of test cases. The description of TT test cases follows.
• The first and only line of each test case contains three space-separated integers NN, KK and LL.

### Output

For each test case:

• If there is no valid assignment of bowlers to overs, print a single line containing the integer −1−1.
• Otherwise, print a single line containing NN space-separated integers. For each valid ii, the ii-th of these integers should be the number of the player assigned as the bowler for the ii-th over.

### Constraints

• 1≤T≤301≤T≤30
• 1≤N,K,L≤10,0001≤N,K,L≤10,000

```2
4 3 2
5 4 1
```

### Example Output

```1 2 3 2
-1
```

### Explanation

Example case 1: The following is a valid assignment:

• Bowler 1 bowls the 11-st over.
• Bowler 2 bowls the 22-nd and 44-th overs.
• Bowler 3 bowls the 33-rd over.

It is valid since no bowler bowls more than 22 overs and each two consecutive overs have different bowlers.

Example case 2: There is no valid assignment in which each of 44 players bowls at most 11 over out of 55.

## Bowling Strategy – CodeChef Solution in JAVA

```import java.util.*;
import java.lang.*;
import java.io.*;
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
Scanner sc = new Scanner(System.in);
int T = sc.nextInt();
while(T-- >0)
{
int N = sc.nextInt();
int K = sc.nextInt();
int L = sc.nextInt();
if((N>K*L) || (K == 1 && N>1))
{
System.out.println(-1);
}
else
{
int count = 0;
for (int i=0; i<L; i++)
{
for (int j=0; j<K; j++)
{
if(count<N)
{
System.out.print(j+1);
System.out.print(" ");
count++;
}
else
{
break;
}
}
if(count<N)
{
continue;
}
else
{
break;
}
}
System.out.println("");
}
}
}
}
```

## Bowling Strategy – CodeChef Solution in CPP

```#include <iostream>
using namespace std;
int main() {
int T, N, K, L;
cin >> T;
for (int i = 0; i < T; i++) {
cin >> N >> K >> L;
if (N == 1) cout << 1;
else if (K != 1 && N <= K * L) {
for(int j = 0; j < N; j++) {
cout << (j % K) + 1 << " ";
}
} else cout << -1 ;
cout << endl;
}
}```

## Bowling Strategy – CodeChef Solution in Python

```from sys import stdin,stdout