-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCandy Boxes.cpp
More file actions
51 lines (51 loc) · 1.22 KB
/
Candy Boxes.cpp
File metadata and controls
51 lines (51 loc) · 1.22 KB
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
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define sf(a) scanf("%d",&a)
#define pf(a) printf("%d\n",a)
#define mem(a,b) memset(a,b,sizeof(a))
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define pb push_back
#define F first
#define S second
#define Check cout<< "Done in " << clock() / CLOCKS_PER_SEC <<" sec"<< endl;
#define FastRead ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
int main()
{
int n,m,t,x;
cin >> n >> m;
int a;
vector < int > v,ans;
vector < int > :: iterator it;
for(int i=0;i<n;i++)
cin >> a , v.push_back(a);
queue < int > q;
while(m--)
{
cin >> t;
if(t == 1)
{
cin >> x;
if(v[x-1] == 0)
{
q.pop();
ans.push_back(x);
}
else
v[x-1]--;
}
else
{
q.push(1);
}
}
while(q.size())
{
ans.push_back(1);
q.pop();
}
for(int i=0;i<ans.size();i++)
cout << ans[i] << endl;
}