제출 #971127

#제출 시각아이디문제언어결과실행 시간메모리
97112712345678카니발 티켓 (IOI20_tickets)C++17
27 / 100
3101 ms108624 KiB
#include "tickets.h" #include <bits/stdc++.h> using namespace std; #define ll long long const int nx=1505; pair<ll, int> dp[nx][nx]; long long find_maximum(int k, std::vector<std::vector<int>> x) { ll n = x.size(), ans=0, cnt=0; ll m = x[0].size(), l[nx], r[nx]; vector<vector<int>> res(n, vector<int> (m, -1)); for (int i=1; i<=n; i++) l[i]=0, r[i]=m-1; for (int i=1; i<=n; i++) dp[0][i].first=-1e18; while (k--) { for (int i=1; i<=n; i++) { for (int j=0; j<=i; j++) { dp[i][j].first=-1e18; if (j!=0) dp[i][j]=max(dp[i][j], {dp[i-1][j-1].first-x[i-1][l[i]], 1}); if (j!=i) dp[i][j]=max(dp[i][j], {dp[i-1][j].first+x[i-1][r[i]], 0}); } } auto cur=dp[n][n/2]; int cj=n/2; for (int i=n; i>=1; i--) { if (cur.second) res[i-1][l[i]++]=cnt; else res[i-1][r[i]--]=cnt; if (cur.second) cur=dp[i-1][--cj]; else cur=dp[i-1][cj]; } ans+=dp[n][n/2].first; cnt++; } allocate_tickets(res); 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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...