0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-10 02:38:49 +00:00

B - At Most 3 (Judge ver.)

https://atcoder.jp/contests/abc251/submissions/31667423
This commit is contained in:
Baoshuo Ren 2022-05-14 20:16:50 +08:00
parent 6040ab640e
commit ad33854e63
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68

52
AtCoder/ABC251/B/B.cpp Normal file
View File

@ -0,0 +1,52 @@
#include <iostream>
using std::cin;
using std::cout;
const char endl = '\n';
const int N = 305;
int n, w, a[N], ans;
bool vis[1000005];
int main() {
std::ios::sync_with_stdio(false);
cin >> n >> w;
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
for (int i = 1; i <= n - 2; i++) {
for (int j = i + 1; j <= n - 1; j++) {
for (int k = j + 1; k <= n; k++) {
if (a[i] + a[j] + a[k] <= w) {
vis[a[i] + a[j] + a[k]] = true;
}
}
}
}
for (int i = 1; i <= n - 1; i++) {
for (int j = i + 1; j <= n; j++) {
if (a[i] + a[j] <= w) {
vis[a[i] + a[j]] = true;
}
}
}
for (int i = 1; i <= n; i++) {
if (a[i] <= w) {
vis[a[i]] = true;
}
}
for (int i = 1; i <= 1000000; i++) {
if (vis[i]) ans++;
}
cout << ans << endl;
return 0;
}