제출 #638947

#제출 시각아이디문제언어결과실행 시간메모리
638947slime카니발 티켓 (IOI20_tickets)C++14
27 / 100
475 ms69020 KiB
#include "tickets.h" #include "bits/stdc++.h" using namespace std; long long find_maximum(int k, std::vector<std::vector<int>> x) { int n = x.size(); int m = x[0].size(); std::vector<std::vector<int>> answer; for (int i = 0; i < n; i++) { std::vector<int> row(m); for (int j = 0; j < m; j++) { row[j] = -1; } answer.push_back(row); } long long dp[n+1][n+1]; // number of max, index range for(int i=0; i<=n; i++) { for(int j=0; j<=n; j++) { dp[i][j] = -1e16; } } dp[0][0] = 0; for(int i=0; i<=n; i++) { for(int j=1; j<=n; j++) { // choose max if(i > 0) dp[i][j] = max(dp[i][j], dp[i-1][j-1] + x[j-1][m-1]); // choose min dp[i][j] = max(dp[i][j], dp[i][j-1] - x[j-1][0]); } } int f = n/2; for(int i=n; i>=1; i--) { if(f > 0 && dp[f][i] == dp[f-1][i-1] + x[i-1][m-1]) { answer[i-1][m-1] = 0; f--; } else { answer[i-1][0] = 0; } } allocate_tickets(answer); return dp[n / 2][n]; }
#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...