Submission #1045290

#TimeUsernameProblemLanguageResultExecution timeMemory
1045290mariaclaraCarnival Tickets (IOI20_tickets)C++17
27 / 100
276 ms73236 KiB
#include "tickets.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> pii; #define all(x) x.begin(), x.end() #define sz(x) (int)x.size() #define mk make_pair #define pb push_back #define fr first #define sc second ll find_maximum(int k, vector<vector<int>> x) { int n = sz(x); int m = sz(x[0]); vector<ll> dp(n/2+1), last(n/2+1); vector<vector<int>> ans(n); vector<vector<bool>> pai(n); for(int i = 0; i < n; i++) { ans[i].resize(m, -1); pai[i].resize(n/2+1); dp[0] -= x[i][0]; for(int j = 1; j <= n/2; j++) { ll a = last[j] - (ll)x[i][0], b = last[j-1] + (ll)x[i].back(); if(a > b) pai[i][j] = 0, dp[j] = a; else pai[i][j] = 1, dp[j] = b; //cout << "[" << i << ", " << j << "] = " << dp[j] << "\n"; } last = dp; } for(int i = n-1, j = n/2; i >= 0; i--) { if(pai[i][j]) ans[i][m-1] = 0, j--; else ans[i][0] = 0; } allocate_tickets(ans); return dp[n/2]; }
#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...