結果

問題 No.3014 岩井満足性問題
ユーザー porkleoi
提出日時 2025-01-25 14:31:11
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 774 ms / 3,000 ms
コード長 4,975 bytes
コンパイル時間 3,472 ms
コンパイル使用メモリ 285,416 KB
実行使用メモリ 7,192 KB
最終ジャッジ日時 2025-01-25 23:22:46
合計ジャッジ時間 10,429 ms
ジャッジサーバーID
(参考情報)
judge7 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep2(i, s, n) for (int i = s; i <= n; i++)
#define rep3(i, s, n, d) for (int i = s; i <= n; i += d)
#define rep4(i, s, n, d) for (int i = s; i >= n; i += d)
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<vvvi> vvvvi;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<vvc> vvvc;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
typedef vector<vvvll> vvvvll;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef vector<ld> vld;
typedef vector<vld> vvld;
typedef vector<vvld> vvvld;
typedef vector<bool> vb;
typedef vector<vd> vvb;
typedef vector<vvd> vvvb;
typedef vector<pair<int, int>> vpi;
typedef vector<pair<ll, ll>> vpll;
typedef pair<int, int> pi;
typedef vector<pi> vpi;
typedef vector<vpi> vvpi;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef tuple<int, int, int> tui3;
typedef tuple<ll, ll, ll> tull3;
typedef priority_queue<int, vector<int>, greater<int>> pqi;
typedef priority_queue<vi, vector<vi>, greater<vi>> pqvi;
typedef priority_queue<pi, vector<pi>, greater<pi>> pqpi;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqll;
typedef priority_queue<vll, vector<vll>, greater<vll>> pqvll;
typedef priority_queue<pll, vector<pll>, greater<pll>> pqpll;
typedef priority_queue<pll, vector<pll>, less<pll>> rpqpll;
typedef priority_queue<int, vector<int>, less<int>> rpqi;
typedef priority_queue<vi, vector<vi>, less<vi>> rpqvi;
typedef priority_queue<tui3, vector<tui3>, greater<tui3>> pqtui3;
typedef priority_queue<tui3, vector<tui3>, less<tui3>> rpqtui3;
typedef priority_queue<tull3, vector<tull3>, greater<tull3>> pqtull3;
typedef priority_queue<tull3, vector<tull3>, less<tull3>> rpqtull3;
#define yes(ans) if(ans)cout << "yes"<< endl; else cout << "no" << endl
#define Yes(ans) if(ans)cout << "Yes"<< endl; else cout << "No" << endl
#define YES(ans) if(ans)cout << "YES"<< endl ;else cout << "NO" << endl
#define printv(vec) {rep(i, vec.size()) cout << vec[i] << ' '; cout << endl;}
#define printvv(vec) rep(i, vec.size()) {rep(j, vec[i].size()) cout << vec[i][j] << ' '; cout << endl;};
#define printvvv(vec) rep(i, vec.size()) { rep(j, vec[i].size()) { rep(k, vec[i][j].size()) cout << vec[i][j][k] << ' '; cout << "	"; }cout << endl; };
#define all1(x) x.begin(),x.end()
#define all2(x) x.rbegin(), x.rend()
#define so(x) sort(all1(x))
#define re(x) reverse(all1(x))
#define rso(x) sort(all2(x))
#define vco(x, a) count(all1(x), a)
#define per(x) next_permutation(all1(x))
#define iINF 2147483647
#define llINF 9223372036854775807
#define INF 4000000000000000000
#define mod 998244353
#define mod2 1000000007
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}

template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "[";
    for (size_t i = 0; i < v.size(); ++i) {
        if (i > 0) os << ", ";
        os << v[i];
    }
    os << "]";
    cout << endl;
    return os;
}

template <typename T>
ostream& operator<<(ostream& os, const set<T>& s) {
    os << "{";
    bool first = true;
    for (const auto& item : s) {
        if (!first) os << ", ";
        os << item;
        first = false;
    }
    os << "}";
    cout << endl;
    return os;
}

// template <typename K, typename V>
// ostream& operator<<(ostream& os, const map<K, V>& m) {
//     os << "{";
//     bool first = true;
//     for (const auto& [key, value] : m) {
//         if (!first) os << ", ";
//         os << key << ": " << value;
//         first = false;
//     }
//     os << "}";
//     return os;
// }

template <typename T1, typename T2>
ostream& operator<<(ostream& os, const pair<T1, T2>& p) {
    os << "(" << p.first << ", " << p.second << ")";
    cout << endl;
    return os;
}

void debug_out() { cout << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cout << H << " ";
    debug_out(T...);
}

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif

int main() {
    //アルゴリズム一覧を見る
    //嘘解法ですか
    ll n, d, k; cin >> n >> d >> k;
    vll A(n), C(n);
    rep(i, n) cin >> A[i];
    rep(i, n) cin >> C[i];
    vvll dp(n+1, vll(k+1, -INF));
    dp[0][0] = 0;
    rep(i, n){
        vvll dp2 = dp;
        ll a = A[i];
        ll c = C[i];
        rep(j, n+1) rep(l, k+1){
            if(dp[j][l]==-INF) continue;
            chmax(dp2[j+1][min(l+c, k)], dp[j][l]+a);
        }
        dp = dp2;
    }
    ll ans = dp[d][k];
    cout << (ans>-INF ? to_string(ans):"No") << endl;
}
0