# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
125877 |
2019-07-06T13:25:14 Z |
tutis |
Popeala (CEOI16_popeala) |
C++17 |
|
2000 ms |
6392 KB |
/*input
2 3 3
4 3 5
101
110
*/
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll modulo = 1000000007;
int main()
{
ios_base::sync_with_stdio(false);
ll N, T, S;
cin >> N >> T >> S;
ll p[T + 1];
p[0] = 0;
for (ll i = 1; i <= T; i++)
{
cin >> p[i];
p[i] += p[i - 1];
}
string res[N];
for (ll i = 0; i < N; i++)
cin >> res[i];
ll dp[S + 1][T + 1];
for (ll a = 0; a <= S; a++)
{
for (ll b = 0; b <= T; b++)
{
dp[a][b] = 1e15;
}
}
dp[0][0] = 0;
int kada[T + 1][N + 1];
for (int i = 0; i <= N; i++)
kada[0][i] = 0;
for (ll b = 1; b <= T; b++)
{
for (ll i = 0; i < N; i++)
{
if (res[i][b - 1] == '0')
{
kada[b][i] = b;
}
else
kada[b][i] = kada[b - 1][i];
}
kada[b][N] = b;
}
for (ll b = 1; b <= T; b++)
sort(kada[b], kada[b] + N + 1);
for (int c = 1; c <= S; c++)
{
for (int b = 1; b <= T; b++)
{
int l = 1;
for (int i = 0; i <= N; i++)
{
int r = kada[b][i];
ll kiek = i;
for (int a = l; a <= r; a++)
{
dp[c][b] = min(dp[c][b], dp[c - 1][a - 1] +
kiek * p[b] - kiek * p[a - 1]);
}
l = r + 1;
}
/*
for (int a = 1; a <= b; a++)
{
ll suma = p[b] - p[a - 1];
ll kiek = lower_bound(kada[b], kada[b] + N, a) - kada[b];
dp[c][b] = min(dp[c][b], dp[c - 1][a - 1] + kiek * suma);
}*/
}
}
for (ll c = 1; c <= S; c++)
{
cout << dp[c][T] << "\n";
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
19 ms |
736 KB |
Output is correct |
2 |
Correct |
18 ms |
632 KB |
Output is correct |
3 |
Correct |
19 ms |
684 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
205 ms |
1928 KB |
Output is correct |
2 |
Correct |
365 ms |
2552 KB |
Output is correct |
3 |
Correct |
631 ms |
3320 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
19 ms |
736 KB |
Output is correct |
4 |
Correct |
18 ms |
632 KB |
Output is correct |
5 |
Correct |
19 ms |
684 KB |
Output is correct |
6 |
Correct |
205 ms |
1928 KB |
Output is correct |
7 |
Correct |
365 ms |
2552 KB |
Output is correct |
8 |
Correct |
631 ms |
3320 KB |
Output is correct |
9 |
Correct |
1581 ms |
5076 KB |
Output is correct |
10 |
Execution timed out |
2077 ms |
6392 KB |
Time limit exceeded |
11 |
Halted |
0 ms |
0 KB |
- |