이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include"holiday.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = (int) 1e5 + 5;
ll dp1[MAXN][2];
ll dp2[MAXN][2];
long long int findMaxAttraction(int n, int start, int d, int attraction[]) {
multiset<ll> st;
for(int j = start; j >= 0; j--){
st.insert(attraction[j]);
int cnt = 0;
ll top = 0;
for(auto u = st.rbegin(); u != st.rend(); u++){
cnt++;
top += *u;
dp1[start - j + cnt][1] = max(dp1[start - j + cnt][1], top);
dp1[2*(start - j) + cnt][0] = max(dp1[2*(start - j) + cnt][0], top);
}
}
st.clear();
for(int j = start + 1; j < n; j++){
st.insert(attraction[j]);
int cnt = 0;
ll top = 0;
for(auto u = st.rbegin(); u != st.rend(); u++){
cnt++;
top += *u;
dp2[j - start + cnt][1] = max(dp2[j - start + cnt][1], top);
dp2[2*(j - start) + cnt][0] = max(dp2[2*(j - start) + cnt][0], top);
}
}
ll ans = 0;
for(int i = 0; i <= d; i++){
ans = max(ans, dp1[i][0] + dp2[d - i][1]);
ans = max(ans, dp1[d - i][1] + dp2[i][0]);
}
return ans;
}
# | 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... |