제출 #536889

#제출 시각아이디문제언어결과실행 시간메모리
536889joelau조교 (CEOI16_popeala)C++14
17 / 100
2082 ms9940 KiB
#include <bits/stdc++.h> using namespace std; long long N,T,S, A[20005], B[55][20005], dp[20005][55]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> N >> T >> S; A[0] = 0; for (long long i = 1; i <= T; ++i) { cin >> A[i]; A[i] += A[i-1]; } for (long long i = 1; i <= N; ++i) for (long long j = 1; j <= T; ++j) { char ch; cin >> ch; B[i][j] = ch-'0' + B[i][j-1]; } memset(dp,-1,sizeof(dp)); dp[0][0] = 0; for (long long i = 1; i <= T; ++i) for (long long j = 1; j <= S && j <= i; ++j) for (long long k = 0; k < i; ++k) if (dp[k][j-1] != -1) { long long num = 0; for (long long n = 1; n <= N; ++n) if (B[n][i] - B[n][k] == i-k) num++; if (dp[i][j] == -1) dp[i][j] = dp[k][j-1] + num * (A[i] - A[k]); else dp[i][j] = min(dp[i][j], dp[k][j-1] + num * (A[i] - A[k])); } for (long long i = 1; i <= S; ++i) cout << dp[T][i] << '\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...