Submission #609462

#TimeUsernameProblemLanguageResultExecution timeMemory
609462VanillaPopeala (CEOI16_popeala)C++17
26 / 100
2061 ms115948 KiB
#include <bits/stdc++.h> using namespace std; typedef long long int64; const int maxt = 2e4 + 2; const int maxn = 51; int dp[maxt][maxn]; // dp[i][j] -> minimum score divinding first i tests in j subtasks int a[maxt]; int pref[maxn][maxt]; int sum[maxn]; int prec[maxt][maxt]; string s[maxn]; int main() { int n,t,mk; cin >> n >> t >> mk; for (int i = 0; i < maxt; i++) for (int j = 0; j < maxn; j++) dp[i][j] = 2e9; for (int i = 1; i <= t; i++){ cin >> a[i]; sum[i] = sum[i-1] + a[i]; } for (int i = 1; i <= n; i++){ cin >> s[i]; for (int j = 1; j <= t; j++){ pref[i][j] = pref[i][j-1] + (s[i][j-1] - '0'); } } for (int i = 1; i <= t; i++){ dp[i][1] = 0; for (int j = 1; j <= n; j++){ if (pref[j][i] == i) dp[i][1]+=sum[i]; } } for (int i = 1; i <= t; i++){ for (int j = 1; j < i; j++){ for (int l = 1; l <= n; l++){ if (pref[l][i] - pref[l][j] == i - j) prec[i][j]+=sum[i] - sum[j]; } } } for (int k = 2; k <= mk; k++){ for (int i = 1; i <= t; i++){ for (int j = 1; j < i; j++){ dp[i][k] = min(dp[i][k], prec[i][j] + dp[j][k-1]); } } } // for (int i = 1; i <= mk; i++){ // for (int j = 1; j <= t; j++){ // cout << dp[j][i] << " "; // } // cout << "\n"; // } for (int i = 1; i <= mk; 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...