Submission #788619

#TimeUsernameProblemLanguageResultExecution timeMemory
788619WLZPopeala (CEOI16_popeala)C++17
100 / 100
356 ms255564 KiB
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; int main() { ios::sync_with_stdio(false); cin.tie(0); int n, t, s; cin >> n >> t >> s; vector<int> points(t + 1, 0); for (int i = 1; i <= t; i++) cin >> points[i], points[i] += points[i - 1]; vector<string> results(n); for (int i = 0; i < n; i++) cin >> results[i], results[i] = "$" + results[i]; vector< vector<int> > dp(t + 1, vector<int>(s + 1, INF)); dp[0][0] = 0; vector< vector< vector<int> > > mn(t + 1, vector< vector<int> >(s + 1, vector<int>(n + 1, INF))); mn[0][0].assign(n + 1, 0); vector<int> last(n, -1), order(n); iota(order.begin(), order.end(), 0); for (int i = 1; i <= t; i++) { for (int j = 0; j < n; j++) if (results[j][i] == '0') last[j] = i; sort(order.begin(), order.end(), [&](int a, int b) { return last[a] < last[b]; }); for (int j = 1; j <= s; j++) { dp[i][j] = mn[i - 1][j - 1][n] + n * points[i]; for (int k = n - 1; k >= 0; k--) { if (last[order[k]] == -1) continue; dp[i][j] = min(dp[i][j], mn[last[order[k]] - 1][j - 1][k] + k * points[i]); } } for (int j = 0; j <= s; j++) { for (int k = 0; k <= n; k++) mn[i][j][k] = min(mn[i - 1][j][k], dp[i][j] - k * points[i]); } } for (int i = 1; i <= s; i++) cout << dp[t][i] << '\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...