답안 #698085

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
698085 2023-02-12T09:47:36 Z abcvuitunggio 조교 (CEOI16_popeala) C++17
17 / 100
2000 ms 9428 KB
#include <iostream>
#include <cstring>
#define int long long
using namespace std;
const int INF=1e18;
int dp[20001][51],n,T,s,t[20001],a[51][20001],cur,mx;
string score[51];
int C(int i, int j){
    int cnt=0;
    for (int k=1;k<=n;k++)
        cnt+=(a[k][j]-a[k][i-1]==j-i+1);
    return (t[j]-t[i-1])*cnt;
}
int f(int i, int j){
    if (j<0)
        return INF;
    if (!i)
        return (j?INF:0);
    if (dp[i][j]!=-1)
        return dp[i][j];
    dp[i][j]=INF;
    for (int k=j;k<=i;k++)
        dp[i][j]=min(dp[i][j],f(k-1,j-1)+C(k,i));
    return dp[i][j];
}
int32_t main(){
    ios_base::sync_with_stdio(NULL);cin.tie(nullptr);
    cin >> n >> T >> s;
    for (int i=1;i<=T;i++){
        cin >> t[i];
        t[i]+=t[i-1];
    }
    for (int i=1;i<=n;i++){
        cin >> score[i];
        for (int j=0;j<T;j++)
            a[i][j+1]=a[i][j]+score[i][j]-'0';
    }
    memset(dp,-1,sizeof(dp));
    for (int i=1;i<=s;i++){
        if (mx==t[T]){
            cout << mx << '\n';
            continue;
        }
        mx=f(T,i);
        cout << mx << '\n';
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 8276 KB Output is correct
2 Correct 4 ms 8404 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 333 ms 8736 KB Output is correct
2 Correct 355 ms 8660 KB Output is correct
3 Correct 325 ms 8660 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2072 ms 9428 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 8276 KB Output is correct
2 Correct 4 ms 8404 KB Output is correct
3 Correct 333 ms 8736 KB Output is correct
4 Correct 355 ms 8660 KB Output is correct
5 Correct 325 ms 8660 KB Output is correct
6 Execution timed out 2072 ms 9428 KB Time limit exceeded
7 Halted 0 ms 0 KB -