Submission #433778

#TimeUsernameProblemLanguageResultExecution timeMemory
433778rqiPopeala (CEOI16_popeala)C++14
26 / 100
2073 ms4044 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> vi; typedef pair<int, int> pi; #define mp make_pair #define f first #define s second #define pb push_back #define sz(x) (int)(x).size() void ckmax(int& a, int b){ a = max(a, b); } void ckmin(ll& a, ll b){ a = min(a, b); } const ll INF = 1e18; int N, T, S; int points[20005]; ll point_sum[20005]; bool solved[55][20005]; ll dp[55][20005]; int main(){ cin.tie(0)->sync_with_stdio(0); cin >> N >> T >> S; for(int i = 1; i <= T; i++){ cin >> points[i]; } for(int i = 1; i <= N; i++){ string s; cin >> s; for(int j = 1; j <= T; j++){ if(s[j-1] == '1'){ solved[i][j] = 1; } } } for(int j = 0; j <= S; j++){ for(int i = 0; i <= T; i++){ dp[j][i] = INF; } } for(int i = 1; i <= T; i++){ point_sum[i] = point_sum[i-1]+points[i]; } dp[0][0] = 0; for(int i = 1; i <= T; i++){ bitset<55> bad; for(int j = i-1; j >= 0; j--){ ll cur_points = 0; for(int k = 1; k <= N; k++){ if(!solved[k][j+1]){ bad[k] = 1; } if(!bad[k]){ cur_points+=point_sum[i]-point_sum[j]; } } for(int k = 1; k <= S; k++){ ckmin(dp[k][i], dp[k-1][j]+cur_points); } } } //switch for loop order // for(int i = 0; i <= T; i++){ // for(int j = 0; j <= S; j++){ // cout << i << " " << j << " " << dp[j][i] << "\n"; // } // } for(int j = 1; j <= S; j++){ cout << dp[j][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...