提出 #70781947


ソースコード 拡げる

#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/tag_and_trait.hpp>
using namespace __gnu_pbds;
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
#define rep(i, m, n) for (ll i = (ll)m; i < (ll)n; i++)
#define drep(i, m, n) for (ll i = m - 1; i >= n; i--)
#define Endl endl
#define all(a) a.begin(), a.end()
#define pr(i, j) make_pair(i, j)
#define isin(x, l, r) (l <= x && x < r)
#define chmin(a, b) a = min(a, b)
#define chmax(a, b) a = max(a, b)
#define srt(ar) sort(ar.begin(), ar.end())
#define rev(ar) reverse(ar.begin(), ar.end())
#define jge(f, s, t) cout << (f ? s : t) << endl
template <typename T>
using ordered_set = tree<T, null_type, std::less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#define printar(ar)             \
    do                          \
    {                           \
        for (auto dbg : ar)     \
        {                       \
            cout << dbg << " "; \
        }                       \
        cout << endl;           \
    } while (0)
const ll inf = 1e18;
const ld pi = 3.14159265358979;
const ld eps = 1e-9;
template <class T, ll n, ll idx = 0>
auto make_vec(const ll (&d)[n], const T &init) noexcept
{
    if constexpr (idx < n)
        return std::vector(d[idx], make_vec<T, n, idx + 1>(d, init));
    else
        return init;
}

template <class T, ll n>
auto make_vec(const ll (&d)[n]) noexcept
{
    return make_vec(d, T{});
}
template <class T>
size_t HashCombine(const size_t seed, const T &v)
{
    return seed ^ (std::hash<T>()(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2));
}
/* pair用 */
template <class T, class S>
struct std::hash<std::pair<T, S>>
{
    size_t operator()(const std::pair<T, S> &keyval) const noexcept
    {
        return HashCombine(std::hash<T>()(keyval.first), keyval.second);
    }
};
/* vector用 */
template <class T>
struct std::hash<std::vector<T>>
{
    size_t operator()(const std::vector<T> &keyval) const noexcept
    {
        size_t s = 0;
        for (auto &&v : keyval)
            s = HashCombine(s, v);
        return s;
    }
};
/* tuple用 */
template <int N>
struct HashTupleCore
{
    template <class Tuple>
    size_t operator()(const Tuple &keyval) const noexcept
    {
        size_t s = HashTupleCore<N - 1>()(keyval);
        return HashCombine(s, std::get<N - 1>(keyval));
    }
};
template <>
struct HashTupleCore<0>
{
    template <class Tuple>
    size_t operator()(const Tuple &keyval) const noexcept { return 0; }
};
template <class... Args>
struct std::hash<std::tuple<Args...>>
{
    size_t operator()(const tuple<Args...> &keyval) const noexcept
    {
        return HashTupleCore<tuple_size<tuple<Args...>>::value>()(keyval);
    }
};
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n;
    cin >> n;
    vector<ll> w(n), h(n), b(n);
    rep(i, 0, n)
    {
        cin >> w[i] >> h[i] >> b[i];
    }
    vector<ll> ar(n * 1000 + 1, -inf);
    ar[n * 500] = 0;
    rep(i, 0, n)
    {
        vector<ll> cp(n * 1000 + 1, -inf);
        rep(j, 0, n * 1000 + 1)
        {
            if (j + w[i] <= n * 1000)
            {
                chmax(cp[j + w[i]], ar[j] + b[i]);
            }
            if (j >= w[i])
            {
                chmax(cp[j - w[i]], ar[j] + h[i]);
            }
        }
        ar = cp;
    }
    ll ans = -inf;
    rep(i, n * 500, n * 1000 + 1)
    {
        chmax(ans, ar[i]);
    }
    cout << ans << endl;
}

提出情報

提出日時
問題 D - Robot Customize
ユーザ a_s_k
言語 C++23 (GCC 15.2.0)
得点 400
コード長 3753 Byte
結果 AC
実行時間 445 ms
メモリ 11280 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 400 / 400
結果
AC × 4
AC × 54
セット名 テストケース
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt, 01_random_19.txt, 01_random_20.txt, 01_random_21.txt, 01_random_22.txt, 01_random_23.txt, 01_random_24.txt, 01_random_25.txt, 01_random_26.txt, 01_random_27.txt, 01_random_28.txt, 01_random_29.txt, 01_random_30.txt, 01_random_31.txt, 01_random_32.txt, 01_random_33.txt, 01_random_34.txt, 01_random_35.txt, 01_random_36.txt, 01_random_37.txt, 01_random_38.txt, 01_random_39.txt, 01_random_40.txt, 01_random_41.txt, 01_random_42.txt, 01_random_43.txt, 01_random_44.txt, 01_random_45.txt, 01_random_46.txt, 01_random_47.txt, 01_random_48.txt, 01_random_49.txt, 01_random_50.txt, 01_random_51.txt, 01_random_52.txt
ケース名 結果 実行時間 メモリ
00_sample_00.txt AC 2 ms 3632 KiB
00_sample_01.txt AC 1 ms 3716 KiB
00_sample_02.txt AC 1 ms 3720 KiB
00_sample_03.txt AC 2 ms 3928 KiB
01_random_03.txt AC 444 ms 11144 KiB
01_random_04.txt AC 444 ms 11084 KiB
01_random_05.txt AC 444 ms 11272 KiB
01_random_06.txt AC 443 ms 11208 KiB
01_random_07.txt AC 444 ms 11168 KiB
01_random_08.txt AC 444 ms 11196 KiB
01_random_09.txt AC 443 ms 11272 KiB
01_random_10.txt AC 443 ms 11272 KiB
01_random_11.txt AC 443 ms 11280 KiB
01_random_12.txt AC 264 ms 9404 KiB
01_random_13.txt AC 96 ms 7000 KiB
01_random_14.txt AC 78 ms 6476 KiB
01_random_15.txt AC 158 ms 8012 KiB
01_random_16.txt AC 49 ms 6136 KiB
01_random_17.txt AC 443 ms 11212 KiB
01_random_18.txt AC 444 ms 11156 KiB
01_random_19.txt AC 443 ms 11252 KiB
01_random_20.txt AC 443 ms 11144 KiB
01_random_21.txt AC 444 ms 11252 KiB
01_random_22.txt AC 81 ms 6876 KiB
01_random_23.txt AC 2 ms 4012 KiB
01_random_24.txt AC 1 ms 3692 KiB
01_random_25.txt AC 443 ms 11208 KiB
01_random_26.txt AC 444 ms 11180 KiB
01_random_27.txt AC 443 ms 11156 KiB
01_random_28.txt AC 445 ms 11084 KiB
01_random_29.txt AC 442 ms 11220 KiB
01_random_30.txt AC 435 ms 11052 KiB
01_random_31.txt AC 314 ms 9996 KiB
01_random_32.txt AC 144 ms 7728 KiB
01_random_33.txt AC 1 ms 3692 KiB
01_random_34.txt AC 1 ms 3720 KiB
01_random_35.txt AC 442 ms 11084 KiB
01_random_36.txt AC 442 ms 11136 KiB
01_random_37.txt AC 444 ms 11144 KiB
01_random_38.txt AC 441 ms 11196 KiB
01_random_39.txt AC 438 ms 11196 KiB
01_random_40.txt AC 440 ms 11140 KiB
01_random_41.txt AC 439 ms 11156 KiB
01_random_42.txt AC 441 ms 11168 KiB
01_random_43.txt AC 163 ms 8060 KiB
01_random_44.txt AC 371 ms 10400 KiB
01_random_45.txt AC 299 ms 9820 KiB
01_random_46.txt AC 14 ms 4808 KiB
01_random_47.txt AC 112 ms 7244 KiB
01_random_48.txt AC 442 ms 11168 KiB
01_random_49.txt AC 441 ms 11272 KiB
01_random_50.txt AC 442 ms 11208 KiB
01_random_51.txt AC 6 ms 4256 KiB
01_random_52.txt AC 71 ms 6532 KiB