提出 #70773236


ソースコード 拡げる

#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;
//using mint = modint1000000007;
//const int mod = 1000000007;
//using mint = modint998244353;
//const int mod = 998244353;
//const int INF = 1e9;
const long long LINF = 1e18;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i,l,r)for(int i=(l);i<(r);++i)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; --i)
#define rrep2(i,l,r)for(int i=(r) - 1;i>=(l);--i)
#define all(x) (x).begin(),(x).end()
#define allR(x) (x).rbegin(),(x).rend()
#define P pair<int,int>
template<typename A, typename B> inline bool chmax(A & a, const B & b) { if (a < b) { a = b; return true; } return false; }
template<typename A, typename B> inline bool chmin(A & a, const B & b) { if (a > b) { a = b; return true; } return false; }

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(nullptr);
	int n; cin >> n;
	vector<int>w(n), h(n), b(n);
	rep(i, n)cin >> w[i] >> h[i] >> b[i];
	// h-b
	int offset = 500 * n;
	vector<long long>dp(offset * 2 + 1, -LINF);//
	int sz = dp.size();
	dp[offset] = 0;
	rep(i, n) {
		vector<long long>ndp(offset * 2 + 1, -LINF);
		rep(j, sz) {
			{//h
				int nj = j + w[i];
				if (nj < sz) {
					chmax(ndp[nj], dp[j] + h[i]);
				}
			}
			{//b
				int nj = j - w[i];
				if (0 <= nj) {
					chmax(ndp[nj], dp[j] + b[i]);
				}
			}
		}
		swap(ndp, dp);
	}
	long long ans = -LINF;
	rep(i, offset + 1)chmax(ans, dp[i]);
	cout << ans << endl;
	return 0;
}

提出情報

提出日時
問題 D - Robot Customize
ユーザ kwm_t
言語 C++23 (GCC 15.2.0)
得点 400
コード長 1537 Byte
結果 AC
実行時間 318 ms
メモリ 11272 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 1 ms 3552 KiB
00_sample_01.txt AC 1 ms 3580 KiB
00_sample_02.txt AC 1 ms 3696 KiB
00_sample_03.txt AC 2 ms 3828 KiB
01_random_03.txt AC 282 ms 11156 KiB
01_random_04.txt AC 281 ms 11152 KiB
01_random_05.txt AC 287 ms 11052 KiB
01_random_06.txt AC 284 ms 11152 KiB
01_random_07.txt AC 281 ms 11268 KiB
01_random_08.txt AC 282 ms 11204 KiB
01_random_09.txt AC 287 ms 11156 KiB
01_random_10.txt AC 285 ms 11216 KiB
01_random_11.txt AC 288 ms 11192 KiB
01_random_12.txt AC 170 ms 9408 KiB
01_random_13.txt AC 63 ms 6996 KiB
01_random_14.txt AC 52 ms 6696 KiB
01_random_15.txt AC 101 ms 7996 KiB
01_random_16.txt AC 35 ms 6004 KiB
01_random_17.txt AC 283 ms 11192 KiB
01_random_18.txt AC 287 ms 11176 KiB
01_random_19.txt AC 283 ms 11168 KiB
01_random_20.txt AC 283 ms 11200 KiB
01_random_21.txt AC 285 ms 11188 KiB
01_random_22.txt AC 54 ms 6744 KiB
01_random_23.txt AC 2 ms 3828 KiB
01_random_24.txt AC 1 ms 3756 KiB
01_random_25.txt AC 288 ms 11268 KiB
01_random_26.txt AC 290 ms 11160 KiB
01_random_27.txt AC 291 ms 11196 KiB
01_random_28.txt AC 291 ms 11140 KiB
01_random_29.txt AC 288 ms 11188 KiB
01_random_30.txt AC 291 ms 11132 KiB
01_random_31.txt AC 204 ms 9848 KiB
01_random_32.txt AC 98 ms 7924 KiB
01_random_33.txt AC 1 ms 3716 KiB
01_random_34.txt AC 1 ms 3636 KiB
01_random_35.txt AC 282 ms 11152 KiB
01_random_36.txt AC 280 ms 11204 KiB
01_random_37.txt AC 283 ms 11128 KiB
01_random_38.txt AC 283 ms 11272 KiB
01_random_39.txt AC 291 ms 11148 KiB
01_random_40.txt AC 286 ms 11200 KiB
01_random_41.txt AC 289 ms 11148 KiB
01_random_42.txt AC 284 ms 11192 KiB
01_random_43.txt AC 106 ms 8076 KiB
01_random_44.txt AC 237 ms 10536 KiB
01_random_45.txt AC 193 ms 9820 KiB
01_random_46.txt AC 12 ms 4892 KiB
01_random_47.txt AC 74 ms 7296 KiB
01_random_48.txt AC 275 ms 11208 KiB
01_random_49.txt AC 318 ms 11176 KiB
01_random_50.txt AC 292 ms 11196 KiB
01_random_51.txt AC 5 ms 4340 KiB
01_random_52.txt AC 47 ms 6652 KiB