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 Rubidium_Chloride @ 2020-07-18 11:37:22
UB?
by dead_X @ 2020-07-18 11:38:15
ub ub ub
by registerGen @ 2020-07-18 11:39:27
我知道了,是 ub,到 这里 试一下
by 绝顶我为峰 @ 2020-07-18 11:40:30
ububub
by cq_loves_Capoo @ 2020-07-18 11:41:50
偶前几天刚过
by 添哥 @ 2020-07-18 11:42:40
@GunpowderLog %%%,爆切IOI
by Gunpowder_OI @ 2020-07-18 11:44:21
@xcs112358 啥意思
by Gunpowder_OI @ 2020-07-18 11:44:44
@添哥 fAKe
by Suuon_Kanderu @ 2020-07-18 11:45:08
IOI烤过这题!
by Luckin_Coffee @ 2020-07-18 11:48:27
memset一下或者定义成全局变量??