-
Notifications
You must be signed in to change notification settings - Fork 0
/
Shahblah.cpp
executable file
·48 lines (46 loc) · 1.01 KB
/
Shahblah.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
/* Written By Manav Aggarwal */
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long
int maxVal(ll x, ll y, ll z, ll n)
{
ll table[n+1], i, j;
table[0] = 0;
for (i = 1; i <= n; i++)
table[i] = INT_MIN;
for (i = 1; i <= n; i++)
{
if (x <= i)
{
int sub_res = table[i-x];
if (sub_res + 1 > table[i])
table[i] = sub_res + 1;
}
if (y <= i)
{
int sub_res = table[i-y];
if (sub_res + 1 > table[i])
table[i] = sub_res + 1;
}
if (z <= i)
{
int sub_res = table[i-z];
if (sub_res + 1 > table[i])
table[i] = sub_res + 1;
}
}
return table[n];
}
int main()
{
ll t;
cin >> t;
while(t--)
{
ll x, y, z, n;
cin >> n >> x >> y >> z;
cout << maxVal(x, y, z, n) << endl;
}
return 0;
}