UVA Solution 473 – Raucous Rockers –  Solution in C,C++ – Volume 4

UVA Online Judge Solution 473 – Raucous Rockers | Volume 4
UVA Problem Link – 473 – Raucous Rockers

Problem Name: 473 – Raucous Rockers solution
Problem Number : UVA – 473 – Raucous Rockers
Online Judge : UVA Online Judge Solution
Volume: 4
Solution Language : C plus plus

UVA Online Judge Solution, UVA OJ Solution list, UVA Problems Solution, UVA solver, UVA all problem solution list

UVA Solution 473 – Raucous Rockers Code in CPP:

#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;
int
main() {
int
testcase;
int
n, t, m, i, j, k, x;
scanf("%d", &testcase);
short
dp[2][100][100];
while
(testcase--) {
scanf("%d %d %d", &n, &t, &m);
memset(dp, 0, sizeof(dp));
int
flag = 0, ans = 0;
for
(i = 0; i < n; i++) {
scanf("%d%*c", &x);
for
(j = 1; j <= m; j++) {
for
(k = 0; k <= t; k++) {
// no record in [j] disk
dp[flag][j][k] = max(dp[1-flag][j][k],
max(dp[1-flag][j-1][t], dp[flag][j-1][t]));
// record in [j] disk
if(k >= x)
dp[flag][j][k] = max((int)dp[flag][j][k], dp[1-flag][j][k-x]+1);
if
(dp[flag][j][k] > ans)
ans = dp[flag][j][k];
}
}

flag = 1-flag;
}

printf("%dn", ans);
if
(testcase)
puts("");
}

return
0;
}

Tags: UVA Online Judge Solution, UVA OJ Solution list, UVA Problems Solution, UVA solver, UVA all problem solution list, UVA 473 – Raucous Rockers  code in C, UVA Raucous Rockers  code in C++, UVA 473 – Raucous Rockers solution in C, UVA 473 solution

By Maniruzzaman Akash

Maniruzzaman Akash is a freelance web developer with most popular Laravel PHP frameork and Vue JS

Leave a Reply

Your email address will not be published. Required fields are marked *