답안 #908658

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
908658 2024-01-16T15:59:34 Z vjudge1 조교 (CEOI16_popeala) C++17
0 / 100
7 ms 6236 KB
#include <iostream>
#include <vector>
#include <algorithm>
#include <cassert>
#include <fstream>
#include <bits/stdc++.h>
#define int long long
#warning That's the baby, that's not my baby

using namespace std;

typedef long long ll;

const int TMAX = 2e4;
const int NMAX = 50;
const int SMAX = 50;

int dp[TMAX + 1][SMAX + 1];
int a[TMAX + 1];
bool b[NMAX + 1][TMAX + 1];
int sum[NMAX + 1][TMAX + 1];
int price[TMAX + 1];

signed main() {
  freopen("popeala.in", "r", stdin);
  freopen("popeala.out", "w", stdout);

  int n, t, s;
  std::cin >> n >> t >> s;

  for (int i = 1; i <= t; i++) {
    std::cin >> a[i];
    price[i] = price[i - 1] + a[i];
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= t; j++) {
      char ch;
      std::cin >> ch;
      b[i][j] = ch - '0';
      sum[i][j] = sum[i][j - 1] + b[i][j];
    }
  }

  for (int i = 0; i <= TMAX; i++) {
    for (int j = 0; j <= SMAX; j++) {
      dp[i][j] = 2e9 + 5;
    }
  }

  dp[0][0] = 0;

  for (int i = 1; i <= t; i++) {
    for (int j = 1; j <= s; j++) {
      for (int k = 1; k <= i; k++) {
        int bad = 0;
        for (int p = 1; p <= n; p++) {
          if (sum[p][i] - sum[p][k - 1] == i - k + 1) {
            bad++;
          }
        }
        if ((ll) dp[k - 1][j - 1] + bad * (price[i] - price[k - 1]) < dp[i][j]) {
          dp[i][j] = dp[k - 1][j - 1] + bad * (price[i] - price[k - 1]);
        }
      }
    }
  }

  for (int i = 1; i <= s; i++) {
    std::cout << dp[t][i] << '\n';
  }

  return 0;
}

Compilation message

popeala.cpp:8:2: warning: #warning That's the baby, that's not my baby [-Wcpp]
    8 | #warning That's the baby, that's not my baby
      |  ^~~~~~~
popeala.cpp: In function 'int main()':
popeala.cpp:25:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |   freopen("popeala.in", "r", stdin);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
popeala.cpp:26:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |   freopen("popeala.out", "w", stdout);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 7 ms 6148 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 5 ms 6232 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 6 ms 6236 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 7 ms 6148 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -