Submission #125893

#TimeUsernameProblemLanguageResultExecution timeMemory
125893tutisPopeala (CEOI16_popeala)C++17
26 / 100
2072 ms21240 KiB
/*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 mini { ll A[20000]; ll get(ll x, ll y) { ll ret = 1e15; for (int i = x; i <= y; i++) ret = min(ret, A[i]); return ret; } }; 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); mini xxx[N + 1]; for (int c = 1; c <= S; c++) { for (int x = 0; x <= N; x++) { for (int a = 0; a < T; a++) { xxx[x].A[a] = dp[c - 1][a] - x * p[a]; } } for (int b = 1; b <= T; b++) { int l = 1; for (int x = 0; x <= N; x++) { int r = kada[b][x]; ll mini = xxx[x].get(l - 1, r - 1); 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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...