Submission #237401

#TimeUsernameProblemLanguageResultExecution timeMemory
237401SortingPopeala (CEOI16_popeala)C++14
0 / 100
47 ms2552 KiB
#include <bits/stdc++.h> using namespace std; const int mx_N = 50 + 3; const int mx_S = 50 + 3; const int mx_T = 2e4 + 3; int n, t, s; long long dp[mx_S][mx_T]; long long p[mx_T], a[mx_T][mx_N], b[mx_N]; string r[mx_N]; int main(){ ios::sync_with_stdio(false); cin.tie(NULL); cin >> n >> t >> s; for(int i = 0; i < t; ++i){ cin >> p[i + 1]; p[i + 1] += p[i]; } for(int i = 0; i < n; ++i) cin >> r[i]; for(int i = 0; i < t; ++i) for(int j = 0; j < n; ++j) a[i + 1][j] = (r[j][i] & 1) ? a[i][j] : i + 1; for(int i = 1; i <= t; ++i){ a[i][n] = i; sort(a[i], a[i] + n + 1); } for(int i = 1; i <= t; ++i) dp[0][i] = INT_MAX; dp[0][0] = 0; for(int i = 1; i <= s; ++i){ for(int j = 1; j <= t; ++j){ dp[i][j] = INT_MAX; for(int k = 0; k <= n; ++k) b[k] = INT_MAX; for(int k = 0; k <= n; ++k){ for(int l = a[j - 1][k]; l < a[j][k]; ++l) b[k] = min(dp[i - 1][l] - p[l] * k, b[k]); dp[i][j] = min(b[k] + p[j] * k, dp[i][j]); } //cout << dp[i][j] << " dp[" << i << "][" << j << "]\n"; } dp[i][0] = INT_MAX; cout << dp[i][t] << "\n"; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...