以最大子序列和问题做为基础,通过不断的增加维度来推广一维的模型。也是模型思想的一个很好的例子,这里做复习用哒。。
#include
using namespace std;
const int N = 100;
int A[N];
int n, ans;
void init(){
cin >> n;
for (int i=0;i> A[i];
}
void solve(){
int sum = 0;
for (int i=0;i
#include
#include
using namespace std;
const int M = 101, N = 101;
int A[M][N], S[M][N];
int m, n, ans;
void init(){
cin >> m >> n;
for (int i=1;i<=m;i++)
for (int j=1;j<=n;j++)
scanf("%d", &A[i][j]);
for (int j=1;j<=n;j++){
S[1][j] = A[1][j];
for (int i=2;i<=m;i++)
S[i][j] = S[i-1][j] + A[i][j];
}
ans = 0;
}
void solve(){
for (int l=0;l
#include
#include
using namespace std;
const int H = 33, M = 51, N = 51;
int A[H][M][N], B[M][N], C[N];
int h, m, n, ans;
void init(){
cin >> h >> m >> n;
for (int i=1;i<=h;i++)
for (int j=1;j<=m;j++)
for (int k=1;k<=n;k++)
scanf("%d", &A[i][j][k]);
}
void solve(){
int l, r;
int ll, rr;
int i, j, k;
int sum;
ans = 0;
for (i=1;i<=m;i++)
for (j=1;j<=n;j++)
for (k=2;k<=h;k++)
A[k][i][j] += A[k-1][i][j];
for (l=0;l
Internal link :
https://www.shuizilong.com/house/archives/740
External link :
http://www.rqnoj.cn/Problem.asp?Act=Search&Title=%B3%D4%CE%F7%B9%CF&Type=98
http://acm.hit.edu.cn/judge/show.php?Proid=101357