QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#305414 | #4591. Maxdifficent Group | LeeShoW# | WA | 0ms | 3656kb | C++20 | 853b | 2024-01-15 10:56:19 | 2024-01-15 10:56:19 |
Judging History
answer
#include<iostream>
#include<algorithm>
#include<random>
#include<vector>
#include<chrono>
#include<cmath>
#include<queue>
#include<set>
#include<map>
#define pii pair<int,int>
#define int long long
using namespace std;
signed main(){
int n;
cin>>n;
int all[n+1];
int dp[n+1];
int rdp[n+1];
for(int i=1;i<=n;i++){
cin>>all[i];
}
for(int i=1;i<=n;i++){
if(i==1){
dp[i]=all[i];
}else {
dp[i]=max(dp[i-1]+all[i],all[i]);
}
}
for(int i=n;i>=1;i--){
if(i==n){
rdp[i]=all[i];
}else rdp[i]=min(all[i],rdp[i+1]+all[i]);
}
int ans=-1e10;
for(int i=1;i<n;i++){
//cout<<dp[i]<<" "<<rdp[i+1]<<endl;
ans=max(ans,dp[i]-rdp[i+1]);
}
cout<<ans<<endl;
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3656kb
input:
4 100 -30 -20 50
output:
150
result:
ok single line: '150'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3492kb
input:
5 12 7 4 32 9
output:
46
result:
ok single line: '46'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3552kb
input:
6 -5 10 -5 45 -20 15
output:
70
result:
ok single line: '70'
Test #4:
score: -100
Wrong Answer
time: 0ms
memory: 3592kb
input:
14 1 5 3 4 2 -4 -2 -6 -5 6 4 2 3 9
output:
32
result:
wrong answer 1st lines differ - expected: '41', found: '32'