-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAt_Most_3.cpp
More file actions
84 lines (75 loc) · 2.15 KB
/
At_Most_3.cpp
File metadata and controls
84 lines (75 loc) · 2.15 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#include <bits/stdc++.h>
#define endl '\n'
#define sqr(x) (x) * (x)
#define gcd(x,y) __gcd(x,y)
#define lcm(x,y) ((x/gcd(x,y)) * y)
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define sz(x) (long long)x.size()
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define prec(x) fixed<<setprecision(x)
#define unsyncIO ios_base::sync_with_stdio(false); cin.tie(nullptr)
using ll = long long;
using db = double;
using ld = long double;
using ull = unsigned long long;
const ld pi = acos((ld) - 1);
const int mod = 1e9 + 7;
const ll inf = 1e18;
const ld eps = 1e-9;
const int mx = 1e5;
using namespace std;
#ifndef ONLINE_JUDGE
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1) {
cout << name << " = " << arg1 << endl;
}
template < typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
const char* comma = strchr(names + 1, ',');
cout.write(names, comma - names) << " = " << arg1 << " | ";
__f(comma + 1, args...);
}
#else
#define debug(...)
#endif
int main() {
#ifndef ONLINE_JUDGE
clock_t tStart = clock();
freopen("in.txt", "r", stdin);
freopen("out.txt", "w", stdout);
#endif
unsyncIO;
int n, w;
cin >> n >> w;
int a[n];
for (int i = 0; i < n; i++) cin >> a[i];
unordered_map<ll, bool> flag;
for (int i = 0; i < n; i++) {
if (a[i] <= w) flag[a[i]] = true;
}
for (int i = 0; i < n; i++) {
for (int j = i + 1; j < n; j++) {
ll x = a[i] + a[j];
if (x <= w) flag[x] = true;
}
}
for (int i = 0; i < n; i++) {
for (int j = i + 1; j < n; j++) {
for (int k = j + 1; k < n; k++) {
ll x = a[i] + a[j] + a[k];
if (x <= w) flag[x] = true;
}
}
}
cout << sz(flag) << endl;
#ifndef ONLINE_JUDGE
fprintf(stderr, "\n>> Runtime: %.10Lf\n", (ld) (clock() - tStart) / CLOCKS_PER_SEC);
#endif
return 0;
}