이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include <holiday.h>
#define tt cin.tie(0), cout.tie(0), ios_base::sync_with_stdio(0)
#define fo freopen((NAME+".INP").c_str(), "r", stdin), freopen((NAME+".OUT").c_str(), "w", stdout)
#define ll long long
#define ull unsigned long long
#define i128 __int128
#define db long double
#define sz(a) ((int)(a).size())
#define pb emplace_back
#define pf emplace_front
#define pob pop_back
#define pof pop_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define ins emplace
using namespace std;
const int MOD = 1e9+7, MAXN = 1e5+5;
const string NAME = "";
ll dp[3005][8005];
ll findMaxAttraction(int n, int start, int d, int attraction[]){
ll rs=attraction[start];
dp[start][1]=attraction[start];
for(int i = start; i<n; ++i)
for(int j = i-start+1; j<=d; ++j){
dp[i][j]=max(dp[i][j],dp[i][j-1]);
for(int k = i-1; k>=start; --k)
dp[i][j]=max(dp[i][j],dp[k][j-i+k-1]+attraction[i]), rs=max(rs,dp[i][j]);
}
for(int i = start-1; i>=0; --i)
for(int j = start-i+1; j<=d; ++j){
dp[i][j]=dp[i][j-1];
for(int k = i+1; k<n&&j>k-i; ++k)
dp[i][j]=max(dp[i][j],dp[k][j-k+i-1]+attraction[i]), rs=max(rs,dp[i][j]);
}
return rs;
}
//int n,start,d,a[MAXN];
//int main()
//{
// tt;
// if(fopen((NAME + ".INP").c_str(), "r")) fo;
// cin >> n >> start >> d;
// for(int i = 0; i<n; ++i)
// cin >> a[i];
// cout << findMaxAttraction(n,start,d,a);
//}
//5 2 7
//10 2 20 30 1
//testing
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |