# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
146293 |
2019-08-23T10:20:35 Z |
lyc |
Popeala (CEOI16_popeala) |
C++14 |
|
3 ms |
632 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef pair<ii, int> ri3;
#define mp make_pair
#define pb push_back
#define fi first
#define sc second
#define SZ(x) (int)(x).size()
#define ALL(x) begin(x), end(x)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define RFOR(i, a, b) for (int i = a; i >= b; --i)
const int INF = 2e9+10;
const int MAXT = 20005;
const int MAXN = 55;
const int MAXS = 55;
int N, T, S;
int P[MAXN];
char R[MAXN][MAXT];
int res[MAXN][MAXS];
int cost[MAXT];
vector<int> flip[MAXN];
int main() {
//freopen("in.txt", "r", stdin);
ios::sync_with_stdio(false);
cin.tie(0);
cin >> N >> T >> S;
FOR(i,1,T) { cin >> P[i]; P[i] += P[i-1]; }
FOR(i,1,N) {
cin >> (R[i]+1);
FOR(j,1,T) {
if (R[i][j] == '0') flip[i].push_back(j);
}
flip[i].push_back(T+1);
}
//FOR(i,1,N) { FOR(j,1,T) { cout << R[i][j] << " "; } cout << endl; }
res[T+1][0] = 0; FOR(x,1,S) res[T+1][x] = INF;
RFOR(i,T,1) {
vector<int> die;
die.push_back(i);
FOR(j,1,N) die.push_back(*lower_bound(ALL(flip[j]), i));
sort(ALL(die));
FOR(j,i,T) cost[j] = (P[j]-P[i-1]) * (die.end() - upper_bound(ALL(die), j));
res[i][1] = cost[T];
FOR(x,2,S) {
res[i][x] = INF;
FOR(j,i,T) {
int nxt = res[j+1][x-1];
if (nxt != INF) res[i][x] = min(res[i][x], nxt + cost[j]);
}
//cout << i << " " << x << " :: " << res[i][x] << endl;
}
}
FOR(i,1,S) cout << res[1][i] << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
504 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
3 ms |
632 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
3 ms |
504 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
504 KB |
Output is correct |
3 |
Runtime error |
3 ms |
632 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
4 |
Halted |
0 ms |
0 KB |
- |