Skip to content

Commit b8a48b7

Browse files
authored
Merge pull request #46 from aayush96692/patch-3
queue
2 parents 93429e6 + 8b0f769 commit b8a48b7

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

queue

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#include<iostream>
2+
using namespace std;
3+
4+
int main()
5+
{
6+
int T,N,M,K,L,a[1000],time=0,ans[1000],p=0,k;
7+
cin>>T;
8+
for(int i=0;i<T;i++)
9+
{
10+
cin>>N>>M>>K>>L;
11+
}
12+
for(int i=0;i<N;i++)
13+
{
14+
cin>>a[i];
15+
}
16+
for(int j=0;j<N+M+1;j++)
17+
{
18+
time++;
19+
if(time==L)
20+
M--;
21+
for(k=0;k<N;k++)
22+
{
23+
if(time==a[k])
24+
{
25+
N--;
26+
M++;
27+
break;
28+
}
29+
}
30+
if(time<K){
31+
if(M*L<=a[k])
32+
{
33+
ans[p]=time;
34+
p++;
35+
}
36+
}
37+
}
38+
for(int i=0;i<T;i++){
39+
cout<<ans[i]<<endl;
40+
}
41+
return 0;
42+
43+
}

0 commit comments

Comments
 (0)