Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
gzshawnliang committed Jan 30, 2019
1 parent 7223f00 commit 7b01155
Show file tree
Hide file tree
Showing 6 changed files with 219 additions and 84 deletions.
2 changes: 1 addition & 1 deletion myCpps/!-OJcreater.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
using namespace std;

//***************************************
const string CPPfile = "JillRidesAgain_UVA507"; //*
const string CPPfile = "garbageHeap_UVA10755"; //*
//***************************************

ifstream fin(CPPfile + ".cpp");
Expand Down
68 changes: 68 additions & 0 deletions myCpps/garbageHeap_UVA10755.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#include <bits/stdc++.h>

using namespace std;

ifstream fin("garbageHeap_UVA10755.in");
ofstream fout("garbageHeap_UVA10755.out");

const int N = 21;

int main()
{
int testCase; fin >> testCase;
for (int t = 1; t <= testCase; ++t)
{
if (t > 1) fout << '\n';

int A, B, C; fin >> A >> B >> C;

vector<vector<vector<long long>>> g(A + 1, vector<vector<long long>>(B + 1, vector<long long>(C + 1, 0)));
vector<vector<vector<vector<long long>>>> s(B + 1, vector<vector<vector<long long>>>(B + 1, vector<vector<long long>>(C + 1, vector<long long>(C + 1, 0)))),
dp(B + 1, vector<vector<vector<long long>>>(B + 1, vector<vector<long long>>(C + 1, vector<long long>(C + 1, 0))));

for (int a = 1; a <= A; ++a)
{
for (int b = 1; b <= B; ++b)
{
for (int c = 1; c <= C; ++c)
{
fin >> g[a][b][c];
}
}
}

long long ans = INT_MIN;
for (int a = 1; a <= A; ++a)
{
for (int i = 1; i <= B; ++i)
{
for (int j = i; j <= B; ++j)
{
for (int n = 1; n <= C; ++n)
{
long long res = 0;
for (int m = n; m <= C; ++m)
{
res += g[a][j][m];
s[i][j][n][m] = s[i][j - 1][n][m] + res;
if (a == 1)
{
dp[i][j][n][m] = s[i][j][n][m];
}
else
{
dp[i][j][n][m] = max(s[i][j][n][m], s[i][j][n][m] + dp[i][j][n][m]);
}

ans = max(ans, dp[i][j][n][m]);
}
}
}
}
}

fout << ans << '\n';
}

return 0;
}
Loading

0 comments on commit 7b01155

Please sign in to comment.