답안 #538965

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
538965 2022-03-18T06:12:37 Z ryangohca 조교 (CEOI16_popeala) C++17
0 / 100
82 ms 2236 KB
#include <bits/stdc++.h>
#define int long long
#define pii pair<int, int>
#define ti3 tuple<int, int, int>
#define ti4 tuple<int, int, int, int>
// This is like my secret account; yes it's like that  ~ Baek Jiheon, Feel Good (Secret Code)
using namespace std;
int psum[20001];
int psumt[51][20001];
int n;
string results[51];
int cost(int l, int r){
    int score = psum[r] - psum[l-1];
    int ans = 0;
    for (int i = 0; i < n; i++){
        if (psumt[i][r] - psumt[i][l-1] == r-l+1) ans += score;
    }
    return ans;
}
int dp[20001][51];
void dnc(int s, int e, int x, int y, int k){
    int m = (s+e)/2;
    dp[m][k] = 1e15;
    pii opt = {1e15, 0};
    for (int i = x; i <= min(y, m-1); i++){
        opt = min(opt, {dp[i][k-1] + cost(i+1, m), i});
    }
    dp[m][k] = opt.first;
    if (s < m) dnc(s, m - 1, x, opt.second, k);
    if (m < e) dnc(m+1, e, opt.second, y, k);
}
main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int t, s; cin >> n >> t >> s;
    for (int i = 1; i <= t; i++){
        cin >> psum[i];
        psum[i] += psum[i-1];
    }
    for (int i = 0; i < n; i++){
        for (int j = 1; j <= t; j++){
            char x; cin >> x;
            int g = x - '0';
            psumt[i][j] = g;
            psumt[i][j] += psumt[i][j-1];
        }
    }
    dp[0][0] = 0;
    for (int i = 1; i <= t; i++){
        dp[i][0] = 1e15;
    }
    for (int i = 1; i <= s; i++){
        dp[0][i] = 1e15;
        /*
        for (int j = 1; j <= t; j++){
            dp[j][i] = 1e15;
            for (int k = 0; k < j; k++){
                dp[j][i] = min(dp[j][i], dp[k][i-1] + cost(k+1, j));
            }
        }
        */
        dnc(0, t, 0, t, i);
        cout << dp[t][i] << '\n';
    }
}

Compilation message

popeala.cpp:32:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   32 | main(){
      | ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Incorrect 1 ms 468 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 12 ms 952 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 82 ms 2236 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Incorrect 1 ms 468 KB Output isn't correct
3 Halted 0 ms 0 KB -