제출 #586553

#제출 시각아이디문제언어결과실행 시간메모리
586553SeDunion휴가 (IOI14_holiday)C++17
0 / 100
56 ms65536 KiB
#include"holiday.h" #include<algorithm> #include<iostream> #include<vector> using namespace std; using ll = long long; const int N = 3003; const int D = 2*N + N/2; ll dp[N][D]; ll findMaxAttraction(int n, int start, int d, int attraction[]) { ll ans = 0; for (int _ = 0 ; _ < 2 ; ++ _) { for (int i = 0 ; i < N ; ++ i) for (int j = 0 ; j < D ; ++ j) { dp[i][j] = 0; } for (int i = 0 ; i < n ; ++ i) { for (int j = 0 ; j <= d ; ++ j) { if (j > 0) dp[i][j] = max(dp[i][j], (ll)attraction[i]); if (i > 0 && j > 0) dp[i][j] = max(dp[i][j], dp[i - 1][j - 1]); if (i > 0 && j > 1) dp[i][j] = max(dp[i][j], dp[i - 1][j - 2] + attraction[i]); if (j > 0) dp[i][j] = max(dp[i][j], dp[i][j - 1]); } } for (int i = start ; i < n ; ++ i) { int x = d - (i - start); if (x >= 0) ans = max(ans, dp[i][x]); } reverse(attraction, attraction + n); start = n - start - 1; } 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...