제출 #307172

#제출 시각아이디문제언어결과실행 시간메모리
307172Ruxandra985카니발 티켓 (IOI20_tickets)C++14
27 / 100
756 ms104696 KiB
#include <bits/stdc++.h> #include "tickets.h" #define DIMN 1510 #define MLD 1000000000 using namespace std; long long spl[DIMN][DIMN] , spr[DIMN][DIMN]; int prefix[DIMN] , sufix[DIMN]; int f[DIMN]; vector <long long> dp[DIMN] , tt[DIMN]; long long find_maximum(int k, vector<vector<int>> x) { int n = x.size() , i , j , take , l , r; int m = x[0].size(); long long sol = 0; vector<vector<int>> answer; for (i = 0; i < n; i++) { vector<int> row; row.resize(m , -1); answer.push_back(row); sufix[i] = m - 1; } for (i = 1 ; i <= n ; i++){ for (j = 1 ; j <= m ; j++) spl[i][j] = x[i - 1][j - 1] + spl[i][j - 1]; for (j = m ; j ; j--) spr[i][j] = MLD - x[i - 1][j - 1] + spr[i][j + 1]; } for (i = 0 ; i <= n ; i++){ dp[i].resize(k * n / 2 + 1); tt[i].resize(k * n / 2 + 1); } tt[0][0] = 1; for (i = 1 ; i <= n ; i++){ for (j = 0 ; j <= k * n / 2 && j <= i * k ; j++){ dp[i][j] = 1000000000000000000LL; /// cate intre 0 si k iau de aici for (take = 0 ; take <= j && take <= k ; take++){ if (tt[i - 1][j - take]){ if (dp[i][j] > dp[i - 1][j - take] + spl[i][take] + spr[i][m - (k - take) + 1]){ dp[i][j] = dp[i - 1][j - take] + spl[i][take] + spr[i][m - (k - take) + 1]; tt[i][j] = take + 1; } } } } } sol += 1LL * MLD * k * n / 2 - dp[n][k * n / 2]; i = n; j = k * n / 2; while (i){ l = tt[i][j] - 1; for (r = 0 ; r < l ; r++){ answer[i - 1][r] = r; } for (r = 0 ; r < k - l ; r++){ answer[i - 1][m - 1 - r] = l + r; } j -= l; i--; } allocate_tickets(answer); return sol; }
#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...