Submission #608714

#TimeUsernameProblemLanguageResultExecution timeMemory
608714promaPopeala (CEOI16_popeala)C++17
17 / 100
2055 ms24248 KiB
#include <bits/stdc++.h> //#define int long long #define see(x) cout<<#x<<"="<<x<<endl; #define endl "\n" using namespace std; const int N = 20005; const int INF = 1e9; int n, t, s, points[N]; char results[55][N]; int pref[55][N], sum[N], substak[N][N]; int dp[N][55]; int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); /* freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); */ cin >> n >> t >> s; for (int i = 1; i <= t; i ++) { cin >> points[i]; sum[i] = sum[i-1] + points[i]; } for (int i = 0; i < n; i ++) { for (int j = 1; j <= t; j ++) { cin >> results[i][j]; } } for (int i = 0; i < n; i ++) { for (int j = 1; j <= t; j ++) { pref[i][j] = pref[i][j-1]; if (results[i][j] == '0') pref[i][j] ++; } } for (int i = 1; i <= t; i ++) { for (int j = i; j <= t; j ++) { for (int k = 0; k < n; k ++) { if (pref[k][j] - pref[k][i-1] == 0) substak[i][j] += sum[j] - sum[i-1]; } } } for (int i = 1; i <= t; i ++) { dp[i][1] = substak[1][i]; for (int j = 2; j <= s; j ++) { dp[i][j] = INF; for (int k = j - 1; k < i; k ++) { dp[i][j] = min(dp[i][j], dp[k][j-1] + substak[k+1][i]); } } } for (int i = 1; i <= s; i ++) { cout << dp[t][i] << 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...