Run ID | Author | Problem | Lang | Verdict | Score | Time | Memory | Code Length | Submit Time |
---|---|---|---|---|---|---|---|---|---|
20003 | 桑迪 | 关灯 | C++ | Runtime Error | 0 | 0 MS | 244 KB | 379 | 2021-05-27 21:35:44 |
#include<iostream> using namespace std; int main() { freopen("x14_6.in","r",stdin); freopen("x14_6.out","w",stdout); int i,n,ans,dp[100],a[100]; cin>>n; for(i=1;i<=n;i++) cin>>a[i]; dp[1]=a[1]; ans=a[1]; for(i=2;i<=n;++i){ if(a[i]<=dp[i-1]+a[i]) dp[i]=dp[i-1]+a[i]; else dp[i]=a[i]; if(ans<dp[i]) ans=dp[i]; } cout<<ans; return 0; }