# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
567450 |
2022-05-23T13:30:06 Z |
piOOE |
Popeala (CEOI16_popeala) |
C++17 |
|
2000 ms |
47940 KB |
#include <bits/stdc++.h>
using namespace std;
#define all(x) begin(x), end(x)
#define sz(x) ((int)size(x))
#define trace(x) cout << #x << ": " << (x) << endl;
typedef long long ll;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
const int S = 51, N = 51, T = 4001;
const ll infL = 3e18;
int s, n, t, A[T], ct[T][T], opt[T][S];
ll dp[T][S], pref[T];
bool solved[N][T];
template<typename T>
bool ckmn(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
ll weight(int l, int r) {
ll every = 0;
for (int i = 1; i <= n; ++i) {
ll sum = 0;
for (int j = l; j <= r; ++j) {
if (!solved[i][j]) {
return 0;
}
sum += A[j];
}
every += sum;
}
return every;
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n >> t >> s;
for (int i = 1; i <= t; ++i) {
cin >> A[i];
pref[i] = pref[i - 1] + A[i];
}
for (int i = 1; i <= n; ++i) {
string ss;
cin >> ss;
for (int j = 1; j <= t; ++j) {
solved[i][j] = (ss[j - 1] == '1');
}
}
for (int k = 1; k <= n; k++) {
for (int i = 1; i <= t; i++) {
int cur = solved[k][i];
ct[i][i] += cur;
for (int j = i + 1; j <= t; j++) {
if (solved[k][j] == 0) cur = 0;
ct[i][j] += cur;
}
}
}
fill(dp[0] + 1, dp[0] + s + 1, infL);
for (int i = 1; i <= t; ++i) {
dp[i][1] = pref[i] * ct[1][i];
for (int cnt = s; cnt > 1; --cnt) {
dp[i][cnt] = infL;
for (int j = max(i - 1, (cnt == s ? i - 1 : opt[i][cnt + 1])); j >= cnt - 1; --j) {
if (ckmn(dp[i][cnt], dp[j][cnt - 1] + (pref[i] - pref[j]) * ct[j + 1][i])) {
opt[i][cnt] = j;
}
}
}
}
for (int i = 1; i <= s; ++i)
cout << dp[t][i] << '\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
596 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
16 ms |
3284 KB |
Output is correct |
2 |
Correct |
20 ms |
3324 KB |
Output is correct |
3 |
Correct |
15 ms |
3316 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
750 ms |
20172 KB |
Output is correct |
2 |
Correct |
1715 ms |
32108 KB |
Output is correct |
3 |
Execution timed out |
2074 ms |
47940 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
596 KB |
Output is correct |
3 |
Correct |
16 ms |
3284 KB |
Output is correct |
4 |
Correct |
20 ms |
3324 KB |
Output is correct |
5 |
Correct |
15 ms |
3316 KB |
Output is correct |
6 |
Correct |
750 ms |
20172 KB |
Output is correct |
7 |
Correct |
1715 ms |
32108 KB |
Output is correct |
8 |
Execution timed out |
2074 ms |
47940 KB |
Time limit exceeded |
9 |
Halted |
0 ms |
0 KB |
- |