rilegoule @ 2019-08-18 19:46:35
不多哔哔,直接上代码
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#include<iostream>
#include<cstdio>
using namespace std;
#define max(A,B) (A>B?A:B)
#define re register short int
inline int read()
{
register int x(0),f(0);register char ch(getchar());
while(!isdigit(ch))f|=(ch=='-'),ch=getchar();
while(isdigit(ch))x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
return x=f?-x:x;
}
const int MAXN=1005;
int n,f[MAXN],maxn;
int main()
{
freopen("a.in","r",stdin);
freopen("a.out","w",stdout);
n=read();
for(re i(1);i<=n;++i)
for(re j(i);j>=1;--j)
f[j]=read()+max(f[j-1],f[j]);
for(re i(1);i<=n;++i)
maxn=max(maxn,f[i]);
printf("%d",maxn);
return 0;
}
by Stephen_Curry @ 2019-08-18 19:47:37
@rilegoule 能用freopen吗
by 奎木狼 @ 2019-08-18 19:48:19
基字打错了qwq
by rilegoule @ 2019-08-18 19:48:28
@Stephen_Curry 不能,在我电脑上用freopen,交上去时删了的
by Stephen_Curry @ 2019-08-18 19:48:54
好吧……
by rilegoule @ 2019-08-18 19:49:23
@奎木狼 好吧,不应该写菜基♂的
by Victorique_De_Blois @ 2019-08-18 19:49:36
@小粉兔
by 森岛帆高 @ 2019-08-19 16:09:22
@小蓝兔