Submission #1087535

# Submission time Handle Problem Language Result Execution time Memory
1087535 2024-09-12T21:32:01 Z juicy Popeala (CEOI16_popeala) C++17
8 / 100
27 ms 2560 KB
#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif

const int N = 20005, D = 55, inf = 2e9;

int n, t, s;
int a[N], mi[N];
int lt[N][D], dp[N][D];

int main() {
  ios::sync_with_stdio(false); cin.tie(nullptr);

  cin >> n >> t >> s;
  for (int i = 1; i <= t; ++i) {
    cin >> a[i];
    a[i] += a[i - 1];
  }
  for (int i = 0; i < n; ++i) {
    string s; cin >> s;
    for (int j = 0; j < t; ++j) {
      lt[j + 1][i] = s[j] == '1' ? lt[j][i] : j + 1;
    }
  }
  for (int i = 1; i <= t; ++i) {
    lt[i][n] = i;
    sort(lt[i], lt[i] + n + 1);
  }
  fill(dp[0] + 1, dp[0] + t + 1, inf);
  for (int i = 1; i <= s; ++i) {
    fill(mi, mi + n + 1, inf);
    dp[i][0] = inf;
    for (int j = 1; j <= t; ++j) {
      dp[i][j] = inf;
      for (int k = 0; k <= n; ++k) {
        for (int p = lt[j - 1][k]; p < lt[j][k]; ++p) {
          if (dp[i - 1][p] ^ inf) {
            mi[k] = min(mi[k], dp[i - 1][p] - a[p] * k);
          }
        }
        if (mi[k] ^ inf) {
          dp[i][j] = min(dp[i][j], mi[k] + a[j] * k);
        }
      }
    }
    cout << dp[i][t] << "\n";
  }
  return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 2560 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 27 ms 1104 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 5 ms 2560 KB Output isn't correct
4 Halted 0 ms 0 KB -