Submission #765608

#TimeUsernameProblemLanguageResultExecution timeMemory
765608LucaIlieHomecoming (BOI18_homecoming)C++17
13 / 100
1076 ms118748 KiB
#include <bits/stdc++.h> #include "homecoming.h" using namespace std; const long long INF = 1e16; const int MAX_N = 5000; long long dp[MAX_N + 1][MAX_N + 1]; long long solve( int n, int k, int a[], int b[] ) { long long ans = 0; for ( int l = 0; l <= k; l++ ) { for ( int j = n; j <= n + l; j++ ) dp[n][j] = -INF; dp[n][n + l] = 0; for ( int i = n - 1; i >= 0; i-- ) { dp[i][i] = -INF; if ( i >= l ) { for ( int j = i + 1; j <= n + l; j++ ) dp[i][i] = max( dp[i][i], dp[i + 1][j] ); } for ( int j = i + 1; j <= n + l; j++ ) dp[i][j] = dp[i + 1][j] - b[i] + (j - i >= k ? a[i] : 0); } for ( int j = 0; j <= n + l; j++ ) ans = max( ans, dp[0][j] ); } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...