제출 #586555

#제출 시각아이디문제언어결과실행 시간메모리
586555SeDunion휴가 (IOI14_holiday)C++17
7 / 100
12 ms3956 KiB
#include"holiday.h" #include<algorithm> #include<iostream> #include<vector> using namespace std; using ll = long long; const int N = 222; 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...