forked from iiitv/ChefLib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCHEFCODE.cpp
53 lines (45 loc) · 1012 Bytes
/
CHEFCODE.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
// Code written by Monal
#include "bits/stdc++.h"
using namespace std;
#define l long int
#define ll long long int
#define ull unsigned long long int
#define intwo(n, k) cin>>n>>k
#define inone(tmp) cin>>tmp
#define out(a) cout<<a
#define forn(n) for (int i = 0; i < n; ++i)
#define pb(tmp) products.push(tmp)
#define po() products.pop()
#define pf() products.front()
queue < ull > products;
void update(ull k, ull inp) {
int size = products.size();
forn(size) {
ull popped = pf();
po();
ull tmp = inp * popped;
pb(popped);
if(tmp <= k) // If product with previous elements is less
pb(tmp);
}
}
void solve(int n, ull k) {
forn(n) {
ull tmp;
inone(tmp);
if (tmp <= k) {
update(k, tmp);
pb(tmp);
}
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
int n;
ull k;
intwo(n, k);
solve(n, k);
out(products.size());
return 0;
}