Submission #908743

#TimeUsernameProblemLanguageResultExecution timeMemory
908743vjudge1Popeala (CEOI16_popeala)C++17
100 / 100
216 ms11856 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int T = 2e4 + 7; const int N = 50 + 7; const int INF = 2e9; int n, t, S; int points[T], pref[T]; int dp[N][T], best[T], last[T][N]; string s[N]; int main() { ios::sync_with_stdio(false); cin.tie(0); cin >> n >> t >> S; for (int i = 1; i <= t; ++i) cin >> points[i]; for (int i = 1; i <= t; ++i) pref[i] = pref[i - 1] + points[i]; for (int i = 1; i <= n; ++i) cin >> s[i]; for (int i = 1; i <= n; ++i) s[i] = "#" + s[i]; for (int i = 1; i <= n; i++) { for (int j = 1; j <= t; ++j) { if (s[i][j] == '0') { last[j][i] = j; } else { last[j][i] = last[j - 1][i]; } } } for (int i = 1; i <= t; ++i) { last[i][0] = i; sort(last[i], last[i] + n + 1); } for (int g = 0; g <= S; ++g) for (int i = 0; i <= t; ++i) dp[g][i] = INF; dp[0][0] = 0; for (int i = 1; i <= S; ++i) { for (int j = 0; j <= n; ++j) best[j] = INF; for (int j = 1; j <= t; ++j) { for (int cnt = 0; cnt <= n; ++cnt) { for (int it = last[j - 1][cnt]; it < last[j][cnt]; ++it) best[cnt] = min(best[cnt], dp[i - 1][it] - cnt * pref[it]); dp[i][j] = min(dp[i][j], best[cnt] + cnt * pref[j]); } } } for (int i = 1; i <= S; ++i) cout << dp[i][t] << "\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...