結果
| 問題 | No.3634 Made to order |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-08-22 15:53:57 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
AC
|
| 実行時間 | 210 ms / 2,000 ms |
| + 655µs | |
| コード長 | 883 bytes |
| 記録 | |
| コンパイル時間 | 1,961 ms |
| コンパイル使用メモリ | 220,404 KB |
| 実行使用メモリ | 163,712 KB |
| 最終ジャッジ日時 | 2026-08-22 15:54:05 |
| 合計ジャッジ時間 | 6,345 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge2_0 |
(要ログイン)
| サブタスク | 配点 | 結果 |
|---|---|---|
| サブタスク $1$ | 20 % | AC * 8 |
| サブタスク $2$ | 10 % | AC * 21 |
| サブタスク $3$ | 70 % | AC * 26 |
| 合計 | 3 * 100% = 300 点 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int N,D; cin >> N >> D;
vector<int> A(N),B(N),C(N);
for(int i=0; i<N; i++) cin >> A.at(i) >> B.at(i) >> C.at(i);
int n2 = 1<<N;
vector<vector<int>> dp(n2,vector<int>(D+1,D+1));
dp.at(0).at(0) = 0;
for(int i=0; i<n2-1; i++){
int d1 = 0;
for(int k=0; k<N; k++) if(i&(1<<k)) d1 += A.at(k);
for(int k=0; k<N; k++) if(!(i&(1<<k))) for(int l=0; l<=D; l++) if(dp.at(i).at(l) != D+1){
int d2 = l,d3 = dp.at(i).at(l);
int D1 = d1+A.at(k),D2 = max(D1,l)+B.at(k),D3 = max(D2,d3)+C.at(k);
if(D2 <= D) dp.at(i+(1<<k)).at(D2) = min(dp.at(i+(1<<k)).at(D2),D3);
}
}
if(*min_element(dp.at(n2-1).begin(),dp.at(n2-1).end()) != D+1) cout << "Yes\n";
else cout << "No\n";
}