Gunpowder_OI @ 2020-07-18 11:34:25
#include <bits/stdc++.h>
using namespace std;
int main (){
int n;
cin >> n;
int a[1001][1001];
int dp[1001][1001];
for (int i = 0; i < n; i++)
for (int j = 0; j <= i; j++)
cin >> a[i][j];
dp[0][0] = a[0][0];
for (int i = 1; i < n; i++){
for (int j = 0; j <= i; j++){
dp[i][j] = max (dp[i - 1][j], dp[i - 1][j - 1]) + a[i][j];
}
}
int max = 0;
for (int i = 0; i < n; i++){
if (dp[n - 1][i] > max)max = dp[n - 1][i];
}
cout << max;
return 0;
}
每次都是11分,无奈下载一个样例,结果:
P1216_1.in
5
7
3 8
8 1 0
2 7 4 4
4 5 2 6 5
P1216_1.out
30
我试了很多次,程序结果都是30,但评测就是过不了,求助大佬为什么会这样?
by chen_zhe @ 2020-07-18 11:51:29
变量定义在局部空间里面没初始化就是自己的问题咯,和评测机没半毛钱关系
by 一只书虫仔 @ 2020-07-18 11:59:20
@chen_zhe 您看一下 这个
by Gunpowder_OI @ 2020-07-18 12:00:02
过了,谢谢大佬!!!!!
by jksdijdsic4 @ 2020-07-27 10:05:20
全局变量.
by zty_luogu @ 2020-08-14 21:39:15
我也是诶