forked from kothariji/competitive-programming
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path(CodeChefs) BOWLERS.cpp
60 lines (51 loc) · 969 Bytes
/
(CodeChefs) BOWLERS.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/********************************************
********* Code By Sweta**********************
********************************************/
#include<bits/stdc++.h>
using namespace std;
void eval(){
int n,k,l,temp=0,r=0;
cin>>n>>k>>l;
long long int multi=k*l;
if(multi>=n && k>1){
vector <int> v;
for(int i=0; i<k; i++){
v.push_back(0);
}
while(n>0){
if(v[temp]==0 && temp<k && v[temp]<l){
cout<<temp+1<<" ";
v[temp]+=1;
temp++;
}
else if(temp==k){
temp=0;
r++;
n++;
}
else if(r>0 && v[temp]<l && temp<k){
cout<<temp+1<<" ";
v[temp]+=1;
temp++;
}
else if(v[temp]==l){
temp++;
n++;
}
n--;
}
cout<<endl;
}
else if(k==1 && n==1)
cout<<1<<endl;
else
cout<<-1<<endl;
}
int main(){
int t;
cin>>t;
while(t--){
eval();
}
return 0;
}