#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vii;
typedef pair<ll,ll> pii;
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define pb push_back
const ll M=6e3+10;
const ll inf=2e18;
ll n,k,a[M],b[M],pre[M],suf[M],pm[M],sm[M];
int main() {
ios_base::sync_with_stdio(0),cin.tie(0);
cin>>n>>k;
for(int i=0;i<n;i++)
cin>>a[i];
for(int i=0;i<n;i++)
cin>>b[i];
pre[0]=b[0];
for(int i=1;i<n;i++) {
pre[i]=pre[i-1]-b[i-1]+a[i-1]+b[i];
}
suf[0]=b[0]-a[0];
for(int i=1;i<n;i++) {
suf[i]=suf[i-1]-b[i-1]-a[i]+b[i];
}
pm[0]=pre[0];
for(int i=1;i<n;i++)
pm[i]=max(pre[i],pm[i-1]);
sm[n-1]=suf[n-1];
for(int i=n-2;i>=0;i--)
sm[i]=max(suf[i],sm[i+1]);
ll ans=0;
for(int i=0;i<n-1;i++) {
ans=max(ans,pre[i]+sm[i+1]);
}
cout<<ans<<'\n';
for(int i=0;i<n;i++) {
cout<<0;
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
1 ms |
344 KB |
Partially correct |
2 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
1 ms |
344 KB |
Partially correct |
2 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |