Submission #444198

#TimeUsernameProblemLanguageResultExecution timeMemory
444198prvocisloPopeala (CEOI16_popeala)C++17
100 / 100
375 ms10436 KiB
#include <bits/stdc++.h> typedef long long ll; using namespace std; const int inf = 2e9 + 5; void upd(int &a, int b) { a = min(a, b); } int main() { ios::sync_with_stdio(false); cin.tie(0); int n, t, s; cin >> n >> t >> s; vector<int> pf(t+1, 0); for (int i = 1, x; i <= t; i++) cin >> x, pf[i] = pf[i-1] + x; vector<vector<int> > h(t+1, vector<int>(n+1, 0)); for (int i = 0; i < n; i++) { string s; cin >> s; for (int j = 1; j <= t; j++) { h[j][i] = h[j-1][i]; if (s[j-1] == '0') h[j][i] = j; } } for (int i = 1; i <= t; i++) { h[i][n] = i; sort(h[i].begin(), h[i].end()); } vector<vector<int> > dp(s+1, vector<int>(t+1, inf)); dp[0][0] = 0; for (int i = 1; i <= s; i++) { vector<int> best(n+1, inf); for (int j = 1; j <= t; j++) { for (int k = 0; k <= n; k++) { for (int l = h[j-1][k]; l < h[j][k]; l++) upd(best[k], dp[i-1][l]-pf[l]*k); upd(dp[i][j], best[k]+pf[j]*k); } } cout << dp[i][t] << endl; } 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...