結果
| 問題 | No.3634 Made to order |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-08-21 22:29:31 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,477 bytes |
| 記録 | |
| コンパイル時間 | 1,981 ms |
| コンパイル使用メモリ | 343,068 KB |
| 実行使用メモリ | 9,424 KB |
| 最終ジャッジ日時 | 2026-08-21 22:29:49 |
| 合計ジャッジ時間 | 5,524 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_1 |
(要ログイン)
| サブタスク | 配点 | 結果 |
|---|---|---|
| サブタスク $1$ | 20 % | AC * 8 |
| サブタスク $2$ | 10 % | AC * 14 WA * 7 |
| サブタスク $3$ | 70 % | AC * 17 WA * 9 |
| 合計 | 3 * 20% = 60 点 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define pb push_back
#define all(a) a.begin(), a.end()
#define sz(a) ((int)a.size())
#ifdef Doludu
template <typename T>
ostream& operator << (ostream &o, vector <T> vec) {
o << "{"; int f = 0;
for (T i : vec) o << (f++ ? " " : "") << i;
return o << "}";
}
void bug__(int c, auto ...a) {
cerr << "\e[1;" << c << "m";
(..., (cerr << a << " "));
cerr << "\e[0m" << endl;
}
#define bug_(c, x...) bug__(c, __LINE__, "[" + string(#x) + "]", x)
#define bug(x...) bug_(32, x)
#define bugv(x...) bug_(36, vector(x))
#define safe bug_(33, "safe")
#else
#define bug(x...) void(0)
#define bugv(x...) void(0)
#define safe void(0)
#endif
const int mod = 998244353, N = 300005;
int main() {
ios::sync_with_stdio(false), cin.tie(0);
int n, d;
cin >> n >> d;
vector <array <int, 3>> arr(n);
int tot0 = 0, tot2 = 0;
for (auto &[a, b, c] : arr) cin >> a >> b >> c, tot0 += a, tot2 += c;
vector <int> mnl(1 << n, 1 << 30), mnr(1 << n, 1 << 30);
for (int s = 0; s < 1 << n; ++s) if (__builtin_popcount(s) == n / 2) {
vector <int> ord;
for (int i = 0; i < n; ++i) if (s >> i & 1) {
ord.pb(i);
}
int x = 0, y = 0, z = 0, cur2 = 0;
do {
for (int i : ord) {
x += arr[i][0];
y = max(x, y) + arr[i][1];
z = max(y, z) + arr[i][2];
cur2 += arr[i][2];
}
if (z + tot2 - cur2 <= d) {
mnl[s] = min(mnl[s], y);
}
} while (next_permutation(all(ord)));
}
for (int s = 0; s < 1 << n; ++s) if (__builtin_popcount(s) == (n + 1) / 2) {
vector <int> ord;
for (int i = 0; i < n; ++i) if (s >> i & 1) {
ord.pb(i);
}
int x = 0, y = 0, z = 0, cur0 = 0;
do {
for (int i : ord) {
z += arr[i][2];
y = max(y, z) + arr[i][1];
x = max(x, y) + arr[i][0];
cur0 += arr[i][0];
}
if (x + tot0 - cur0 <= d) {
mnr[s] = min(mnr[s], y);
}
} while (next_permutation(all(ord)));
}
for (int s = 0; s < 1 << n; ++s) if (__builtin_popcount(s) == n / 2) {
if (mnl[s] <= d - mnr[s ^ ((1 << n) - 1)]) {
cout << "Yes\n";
return 0;
}
}
cout << "No\n";
}