답안 #1072250

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1072250 2024-08-23T16:00:15 Z edogawa_something Tricks of the Trade (CEOI23_trade) C++17
0 / 100
221 ms 596560 KB
#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=5e5+10;
const ll inf=2e18;
ll ma[301],dp[M][301],n,k,a[M],b[M],suf[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];
    ll sum=0;
    for(int i=n-1;i>=0;i--) {
        sum-=a[i];
        dp[i][0]=sum;
        for(int j=1;j<=k;j++)
        dp[i][j]=-inf;
    }
    for(int i=n-1;i>=0;i--)
        suf[i]=suf[i+1]+a[i];
    sum=0;
    for(int i=0;i<=k;i++)
        ma[i]=-inf;
    ma[0]=-suf[0];
    for(int i=0;i<n;i++) {
        for(int j=k;j>=1;j--) {
            dp[i][j]=max(dp[i][j],ma[j-1]+b[i]);
            ma[j]=max(ma[j],dp[i][j]);
        }
    }
    ll ans=-1;
    for(int i=0;i<n;i++)
        ans=max(ans,dp[i][k]+suf[i+1]);
    cout<<ans<<'\n';
    for(int i=0;i<n;i++)
        cout<<0;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Partially correct 0 ms 348 KB Partially correct
2 Partially correct 0 ms 348 KB Partially correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 0 ms 348 KB Partially correct
2 Partially correct 0 ms 348 KB Partially correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Partially correct 0 ms 348 KB Partially correct
2 Partially correct 0 ms 348 KB Partially correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Partially correct 0 ms 344 KB Partially correct
2 Incorrect 221 ms 596560 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Partially correct 0 ms 344 KB Partially correct
2 Incorrect 221 ms 596560 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Partially correct 0 ms 348 KB Partially correct
2 Partially correct 0 ms 348 KB Partially correct
3 Partially correct 0 ms 348 KB Partially correct
4 Partially correct 0 ms 348 KB Partially correct
5 Incorrect 0 ms 348 KB Output isn't correct
6 Halted 0 ms 0 KB -