# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
125889 |
2019-07-06T13:50:34 Z |
tutis |
Popeala (CEOI16_popeala) |
C++17 |
|
2000 ms |
33696 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;
struct line
{
ll k;
ll b;
// kx + b
};
struct ST
{
int l, r;
vector<line>K;
ST *left;
ST *right;
ll ans[51];
ST(int l, int r): l(l), r(r)
{
if (l < r)
{
left = new ST(l, (l + r) / 2);
right = new ST((l + r) / 2 + 1, r);
}
}
void fix(const vector<line> &a)
{
if (l < r)
{
left->fix(a);
right->fix(a);
for (int x = 0; x <= 50; x++)
ans[x] = min(left->ans[x], right->ans[x]);
}
else
{
for (int x = 0; x <= 50; x++)
{
ans[x] = a[l].k * x + a[l].b;
}
}
}
ll mini(int x, int y, ll xx)
{
if (x <= l && r <= y)
return ans[xx];
if (r < x || y < l)
return 1e15;
return min(left->mini(x, y, xx), right->mini(x, y, xx));
}
};
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] = 1e11;
}
}
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);
ST medis(0, T);
for (int c = 1; c <= S; c++)
{
vector<line>aaa;
for (int a = 0; a <= T; a++)
{
aaa.push_back(line());
aaa.back().b = dp[c - 1][a];
aaa.back().k = -p[a];
}
medis.fix(aaa);
for (int b = 1; b <= T; b++)
{
int l = 1;
for (int x = 0; x <= N; x++)
{
int r = kada[b][x];
ll mini = medis.mini(l - 1, r - 1, x);
dp[c][b] = min(dp[c][b], mini + x * p[b]);
l = r + 1;
}
}
}
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 |
69 ms |
1144 KB |
Output is correct |
2 |
Correct |
67 ms |
1172 KB |
Output is correct |
3 |
Correct |
70 ms |
1184 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
362 ms |
3948 KB |
Output is correct |
2 |
Correct |
555 ms |
5236 KB |
Output is correct |
3 |
Correct |
804 ms |
6904 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 |
69 ms |
1144 KB |
Output is correct |
4 |
Correct |
67 ms |
1172 KB |
Output is correct |
5 |
Correct |
70 ms |
1184 KB |
Output is correct |
6 |
Correct |
362 ms |
3948 KB |
Output is correct |
7 |
Correct |
555 ms |
5236 KB |
Output is correct |
8 |
Correct |
804 ms |
6904 KB |
Output is correct |
9 |
Correct |
1419 ms |
11072 KB |
Output is correct |
10 |
Correct |
1824 ms |
14436 KB |
Output is correct |
11 |
Execution timed out |
2062 ms |
33696 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |