제출 #983831

#제출 시각아이디문제언어결과실행 시간메모리
983831phoenix0423카니발 티켓 (IOI20_tickets)C++17
27 / 100
2641 ms90768 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> pll; #define pb push_back #define eb emplace_back #include "tickets.h" const int maxn = 1505; const ll INF = 1e18; ll dp[maxn][maxn]; long long find_maximum(int k, std::vector<std::vector<int>> x) { int n = x.size(); int m = x[0].size(); vector<vector<int>> ans(n, vector<int>(m, -1)); ll c = 0; vector<int> l(n, 0), r(n, m - 1); while(k--){ for(int i = 0; i <= n; i++) for(int j = 0; j <= n / 2; j++) dp[i][j] = -INF; dp[0][0] = 0; for(int i = 0; i < n; i++){ for(int j = 0; j <= n / 2; j++){ dp[i + 1][j] = max(dp[i + 1][j], dp[i][j] - x[i][l[i]]); dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + x[i][r[i]]); } } c += dp[n][n / 2]; int cnt = n / 2; for(int i = n - 1; i >= 0; i--){ if(dp[i][cnt] - x[i][l[i]] == dp[i + 1][cnt]){ ans[i][l[i]] = k; l[i] ++; } else{ ans[i][r[i]] = k; r[i] --; cnt--; } } } allocate_tickets(ans); return c; }
#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...