提出 #49649052


ソースコード 拡げる

// clang-format off
#include <bits/stdc++.h>
using namespace std;
#if __has_include(<atcoder/all>)
#include <atcoder/all>
using namespace atcoder;
#endif

#define _overload3(_1,_2,_3,name,...) name
#define _REP(i,n) REPI(i,0,n)
#define REPI(i,a,b) for(int i=int(a);i<int(b);++i)
#define REP(...) _overload3(__VA_ARGS__,REPI,_REP,)(__VA_ARGS__)
#define _RREP(i,n) RREPI(i,n,0)
#define RREPI(i,a,b) for(int i=int(a);i>=int(b);--i)
#define RREP(...) _overload3(__VA_ARGS__,RREPI,_RREP,)(__VA_ARGS__)
#define ALL(a) (a).begin(),(a).end()
#define ALLR(a) (a).rbegin(),(a).rend()
typedef long long ll;
const int INF32 = 1001001001;
const long long INF64 = 1001001001001001001;
struct Init { Init() { ios::sync_with_stdio(0); cin.tie(0); cout << setprecision(15); }} init;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
template<class T> T gcd(T x, T y){ return (x % y) ? gcd(y, x % y) : y; }
template<class T> T lcm(T x, T y){ return x / gcd(x, y) * y; }
template<class T, class... Ts> void output(const T& a, const Ts&... b) { cout << a; (cout << ... << (cout << ' ', b)); cout << '\n'; }
template<class T> void output(vector<T> v) { for (auto u : v) cout << u << ' '; cout << '\n'; };
void yesno(bool is_ok) { cout << (is_ok ? "yes" : "no") << '\n'; }
void YesNo(bool is_ok) { cout << (is_ok ? "Yes" : "No") << '\n'; }
void YESNO(bool is_ok) { cout << (is_ok ? "YES" : "NO") << '\n'; }

// clang-format on
int main() {
    int n;
    cin >> n;
    vector<int> w(n), s(n), v(n);
    REP(i, n) cin >> w[i] >> s[i] >> v[i];
    vector<int> ord(n);
    REP(i, n) ord[i] = i;
    sort(ALL(ord), [&](int a, int b) -> bool {
        return min(s[a], s[b] - w[a]) > min(s[b], s[a] - w[b]);
    });
    vector dp(n + 1, vector<ll>(20005, 0));
    REP(i, n) {
        REP(j, 20005) {
            chmax(dp[i + 1][j], dp[i][j]);
            if (j + w[ord[i]] <= 20000 && j <= s[ord[i]]) {
                chmax(dp[i + 1][j + w[ord[i]]], dp[i][j] + v[ord[i]]);
            }
        }
    }
    ll ans = 0;
    REP(i, 20005) chmax(ans, dp[n][i]);
    output(ans);
}

提出情報

提出日時
問題 X - Tower
ユーザ noko206
言語 C++ 17 (gcc 12.2)
得点 100
コード長 2257 Byte
結果 AC
実行時間 90 ms
メモリ 163676 KiB

コンパイルエラー

Main.cpp: In instantiation of ‘void output(const T&, const Ts& ...) [with T = long long int; Ts = {}]’:
Main.cpp:54:11:   required from here
Main.cpp:26:86: warning: statement has no effect [-Wunused-value]
   26 | template<class T, class... Ts> void output(const T& a, const Ts&... b) { cout << a; (cout << ... << (cout << ' ', b)); cout << '\n'; }
      |                                                                                      ^~~~

ジャッジ結果

セット名 All
得点 / 配点 100 / 100
結果
AC × 25
セット名 テストケース
All 0_00, 0_01, 0_02, 0_03, 1_00, 1_01, 1_02, 1_03, 1_04, 1_05, 1_06, 1_07, 1_08, 1_09, 1_10, 1_11, 1_12, 1_13, 1_14, 1_15, 1_16, 1_17, 1_18, 1_19, 1_20
ケース名 結果 実行時間 メモリ
0_00 AC 1 ms 3852 KiB
0_01 AC 2 ms 4048 KiB
0_02 AC 2 ms 4144 KiB
0_03 AC 2 ms 4756 KiB
1_00 AC 1 ms 3592 KiB
1_01 AC 88 ms 163564 KiB
1_02 AC 87 ms 163672 KiB
1_03 AC 87 ms 163424 KiB
1_04 AC 86 ms 163580 KiB
1_05 AC 87 ms 163320 KiB
1_06 AC 89 ms 163396 KiB
1_07 AC 90 ms 163484 KiB
1_08 AC 89 ms 163196 KiB
1_09 AC 87 ms 163564 KiB
1_10 AC 87 ms 163320 KiB
1_11 AC 88 ms 163388 KiB
1_12 AC 89 ms 163052 KiB
1_13 AC 90 ms 163452 KiB
1_14 AC 89 ms 163408 KiB
1_15 AC 90 ms 163420 KiB
1_16 AC 88 ms 163416 KiB
1_17 AC 88 ms 163676 KiB
1_18 AC 88 ms 163320 KiB
1_19 AC 88 ms 163392 KiB
1_20 AC 88 ms 163320 KiB