이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int T = 2e4 + 7;
const int N = 50 + 7;
const int INF = 2e9;
int n, t, s;
int points[T], task[T], sum[N][T];
int pref[T], dp[T][N];
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cin >> n >> t >> s;
for (int i = 1; i <= t; ++i) cin >> points[i];
for (int i = 1; i <= t; ++i) pref[i] = pref[i - 1] + points[i];
for (int i = 1; i <= n; ++i) {
string s;
cin >> s;
for (int j = 0; j < t; ++j) sum[i][j + 1] = sum[i][j] + s[j] - '0';
}
for (int g = 0; g <= s; ++g) for (int i = 0; i <= t; ++i) dp[i][g] = INF;
dp[0][0] = 0;
for (int g = 1; g <= s; ++g) {
for (int i = 1; i <= t; ++i) {
for (int j = 1; j <= i; ++j) {
int score = 0;
for (int guy = 1; guy <= n; ++guy) {
if (sum[guy][i] - sum[guy][j - 1] == i - j + 1) {
score += pref[i] - pref[j - 1];
}
}
dp[i][g] = min(dp[i][g], dp[j - 1][g - 1] + score);
}
}
}
for (int i = 1; i <= s; ++i) cout << dp[t][i] << "\n";
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |