답안 #598546

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
598546 2022-07-18T13:39:58 Z 1bin 조교 (CEOI16_popeala) C++14
100 / 100
245 ms 10120 KB
#include <bits/stdc++.h>
 
using namespace std;
 
#define all(v) v.begin(), v.end()
typedef long long ll;
const int MAX = 2e4 + 5;
int n, t, s, dp[55][MAX], p[MAX], ix[MAX][55], cand[55], ii[55];
string w;
 
int main(void){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    cin >> n >> t >> s;
    for(int i = 1; i <= t; i++) cin >> p[i], p[i] += p[i - 1];
    for(int i = 1; i <= n; i++){
        cin >> w;
        for(int j = 1; j <= t; j++) ix[j][i - 1] = (w[j - 1] - '0') ? ix[j - 1][i - 1] : j;
    }
    for(int i = 1; i <= t; i++) sort(ix[i], ix[i] + n);
    
    memset(dp, 0x3f, sizeof(dp));
    dp[0][0] = 0;
    for(int i = 1; i <= s; i++){
        memset(cand, 0x3f, sizeof(cand));
        memset(ii, 0, sizeof(ii));
        for(int j = 1; j <= t; j++){
            dp[i][j] = dp[i - 1][j - 1] + n * (p[j] - p[j - 1]);
            for(int k = 0; k < n; k++){
                while(ii[k] < ix[j][k])  cand[k] = min(cand[k], dp[i - 1][ii[k]] - k * p[ii[k]]), ii[k]++;
                dp[i][j] = min(dp[i][j], cand[k] + k * p[j]);
            }
        }
        cout << dp[i][t] << '\n';
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4544 KB Output is correct
2 Correct 2 ms 4564 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 4648 KB Output is correct
2 Correct 8 ms 4692 KB Output is correct
3 Correct 8 ms 4696 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 36 ms 5056 KB Output is correct
2 Correct 55 ms 5460 KB Output is correct
3 Correct 48 ms 5708 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4544 KB Output is correct
2 Correct 2 ms 4564 KB Output is correct
3 Correct 9 ms 4648 KB Output is correct
4 Correct 8 ms 4692 KB Output is correct
5 Correct 8 ms 4696 KB Output is correct
6 Correct 36 ms 5056 KB Output is correct
7 Correct 55 ms 5460 KB Output is correct
8 Correct 48 ms 5708 KB Output is correct
9 Correct 64 ms 6424 KB Output is correct
10 Correct 110 ms 6960 KB Output is correct
11 Correct 172 ms 10080 KB Output is correct
12 Correct 170 ms 10060 KB Output is correct
13 Correct 245 ms 10060 KB Output is correct
14 Correct 228 ms 10120 KB Output is correct
15 Correct 226 ms 10120 KB Output is correct