結果

問題 No.472 平均順位
ユーザー kyawashellkyawashell
提出日時 2018-03-28 12:07:48
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 916 bytes
コンパイル時間 1,925 ms
コンパイル使用メモリ 198,440 KB
実行使用メモリ 101,944 KB
最終ジャッジ日時 2023-09-07 19:21:01
合計ジャッジ時間 6,187 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 TLE -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define mp make_pair
#define fi first
#define sc second
#define INF (1e9)
int W,N,K;
int A[100],B[100];

int dp[51][10001][51];

int main(){
	cin >> W >> N >> K;
	REP(i,N) {
		cin >> A[i] >> B[i];
	}

	REP(i,W + 1) {
		REP(j,K + 1) {
			dp[0][i][j] = 0;
		}
	}

	FOR(i,1,N + 1) {
		REP(j,W + 1) {
			REP(k,K + 1) {
				if(0 <= j - A[i - 1] && 0 <= k - 1)
					dp[i][j][k] = max(dp[i - 1][j][k],dp[i - 1][j - A[i - 1]][k - 1] + B[i - 1]);
				else
					dp[i][j][k] = dp[i - 1][j][k];
			}
		}
	}

	cout << dp[N][W][K] << endl;
	return 0;
}
0