Submission #769127

#TimeUsernameProblemLanguageResultExecution timeMemory
769127t6twotwoCarnival Tickets (IOI20_tickets)C++17
27 / 100
434 ms61664 KiB
#include "tickets.h" #include <bits/stdc++.h> using namespace std; using ll = long long; ll find_maximum(int K, vector<vector<int>> x) { int N = x.size(); int M = x[0].size(); if (M == 1) { allocate_tickets(vector(N, vector{0})); vector<int> v(N); for (int i = 0; i < N; i++) { v[i] = x[i][0]; } sort(v.begin(), v.end()); ll s = 0; for (int i = 0; i < N; i++) { s += abs(v[N / 2] - v[i]); } return s; } if (K == 1) { vector dp(N + 1, vector<ll>(N / 2 + 1, -1e18)); dp[0][0] = 0; for (int i = 0; i < N; i++) { for (int j = 0; j <= N / 2; j++) { if (j < N / 2) { dp[i + 1][j + 1] = dp[i][j] + x[i][M - 1]; } dp[i + 1][j] = max(dp[i + 1][j], dp[i][j] - x[i][0]); } } vector ans(N, vector<int>(M, -1)); for (int i = N - 1, j = N / 2; i >= 0; i--) { if (dp[i][j] - x[i][0] == dp[i + 1][j]) { ans[i][0] = 0; } else { ans[i][M - 1] = 0; j--; } } allocate_tickets(ans); return dp[N][N / 2]; } }

Compilation message (stderr)

tickets.cpp: In function 'll find_maximum(int, std::vector<std::vector<int> >)':
tickets.cpp:44:1: warning: control reaches end of non-void function [-Wreturn-type]
   44 | }
      | ^
#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...