답안 #64127

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
64127 2018-08-03T11:44:00 Z Bodo171 Homecoming (BOI18_homecoming) C++14
0 / 100
40 ms 8752 KB
#include "homecoming.h"
#include <iostream>
using namespace std;
const int nmax=5005;
long long dp[nmax],sum[nmax],sk[nmax],C[nmax];
long long ans,prefmx;
int i,n,rot,k,aux1,aux2;
void solve()
{
    prefmx=0;
    for(i=1;i<=n;i++)
        dp[i]=0;
    for(i=1;i<=n-k+1;i++)
    {
        dp[i]=max(dp[i],dp[i-1]);
        dp[i+k-1]=1LL*max(sum[i]+prefmx-(sk[i+k-1]-sk[i]),dp[i+k-1]);
        prefmx=max(prefmx,dp[i]-sum[i]);
    }
    if(dp[n]>ans) ans=dp[n];
}
long long solve(int N, int K, int *A, int *B)
{
    for(i=0;i<N;i++)
        ans+=1LL*(A[i]-B[i]);
        n=N,k=K;
    for(rot=1;rot<=N;rot++)
    {
        for(i=1;i<=N;i++)
        {
            C[i]=A[i-1]-B[i-1];
            sk[i]=1LL*sk[i-1]+B[i-1];
            sum[i]=1LL*C[i]+sum[i-1];
        }
        solve();
        aux1=A[0];aux2=B[0];
        for(i=0;i<N-1;i++)
            A[i]=A[i+1],B[i]=B[i+1];
        A[N-1]=aux1;B[N-1]=aux2;
    }
    return ans;
}

Compilation message

homecoming.cpp: In function 'long long int solve(int, int, int*, int*)':
homecoming.cpp:23:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
     for(i=0;i<N;i++)
     ^~~
homecoming.cpp:25:9: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
         n=N,k=K;
         ^
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 5 ms 484 KB Output is correct
3 Incorrect 3 ms 484 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 5 ms 484 KB Output is correct
3 Incorrect 3 ms 484 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 40 ms 8752 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 5 ms 484 KB Output is correct
3 Incorrect 3 ms 484 KB Output isn't correct
4 Halted 0 ms 0 KB -