Submission #605989

#TimeUsernameProblemLanguageResultExecution timeMemory
605989maximath_1Popeala (CEOI16_popeala)C++11
100 / 100
262 ms11340 KiB
#include <bits/stdc++.h> using namespace std; const int inf = 1e9 + 5; int n, t, s; int dp[20005][55], val[20005], pre[20005][55]; string ss[55]; int best[55]; int main(){ cin.tie(0) -> sync_with_stdio(0); cin >> n >> t >> s; for(int i = 1; i <= t; i ++){ cin >> val[i]; val[i] += val[i - 1]; } for(int i = 1; i <= n; i ++){ cin >> ss[i]; for(int j = 0; j < t; j ++){ if(ss[i][j] == '1') pre[j + 1][i] = pre[j][i]; else pre[j + 1][i] = j + 1; } } for(int i = 1; i <= t; i ++){ pre[i][0] = i; sort(pre[i], pre[i] + n + 1); } for(int i = 0; i < 20005; i ++) for(int j = 0; j < 55; j ++) dp[i][j] = 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 k = 0; k <= n; k ++){ for(int l = pre[j - 1][k]; l < pre[j][k]; l ++) best[k] = min(best[k], dp[l][i - 1] - val[l] * k); dp[j][i] = min(dp[j][i], best[k] + val[j] * k); } } 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...