forked from bhaveshlohana/HacktoberFest2020-Contributions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathKickstartRoundF_ATMcode.cpp
64 lines (50 loc) · 945 Bytes
/
KickstartRoundF_ATMcode.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
61
62
63
64
#include<iostream>
#include<bits/stdc++.h>
#include<string.h>
#define test int testcase; cin>>testcase; while(testcase--)
#define ll long long int
#define FOR(n) for(int i=1;i<=n;i++)
using namespace std;
int main()
{
int t=0;
test
{
t++;
int n,x;
cin>>n>>x;
ll arr[n];
queue<pair<int, int>> que;
vector<int> ans;
//int count=0,top;
FOR(n)
{
cin>>arr[i];
que.push(make_pair(arr[i],i));
}
pair<int, int> top = que.front();
while(!que.empty())
{
if(top.first <= x)
{
ans.push_back(top.second);
que.pop();
top = que.front();
}
else
{
top.first = top.first - x;
que.pop();
que.push(top);
top = que.front();
}
}
cout<<"Case #"<<t<<": ";
for(int i=0;i<n;i++)
{
cout<<ans[i]<<" ";
}
cout<<endl;
}
return 0;
}