Submission #349970

# Submission time Handle Problem Language Result Execution time Memory
349970 2021-01-18T19:03:39 Z doowey Popeala (CEOI16_popeala) C++14
17 / 100
2000 ms 2028 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

const int N = 20010;
const int M = 55;
const ll inf = (ll)1e18;

ll dp[M][N];
ll sum[N];
int cnt[M][N];

int n, t;

ll cost(int li, int ri){
    ll f1 = sum[ri]-sum[li-1];
    ll f2 = 0;
    for(int i = 1; i <= n; i ++ ){
        f2 += (cnt[i][ri]-cnt[i][li-1]==(ri-li+1));
    }
    return f1 * 1ll * f2;
}

int main(){
    fastIO;
    int s;
    cin >> n >> t >> s;
    for(int i = 0 ; i <= s; i ++ ){
        for(int j =0; j <= t; j ++ ){
            dp[i][j]=inf;
        }
    }
    dp[0][0]=0;
    for(int i = 1; i <= t; i ++ ){
        cin >> sum[i];
        sum[i] += sum[i - 1];
    }
    char q;
    for(int i = 1; i <= n; i ++ ){
        for(int j = 1; j <= t; j ++ ){
            cin >> q;
            cnt[i][j]=q-'0';
            cnt[i][j]+=cnt[i][j-1];
        }
    }
    for(int i = 1; i <= s; i ++ ){
        for(int p = 1; p <= t; p ++ ){
            for(int q = 1; q <= p; q ++ ){
                dp[i][p]=min(dp[i][p],cost(q,p)+dp[i-1][q-1]);
            }
        }
        cout << dp[i][t] << "\n";
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 620 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 377 ms 1132 KB Output is correct
2 Correct 349 ms 1132 KB Output is correct
3 Correct 380 ms 1260 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 2037 ms 2028 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 620 KB Output is correct
3 Correct 377 ms 1132 KB Output is correct
4 Correct 349 ms 1132 KB Output is correct
5 Correct 380 ms 1260 KB Output is correct
6 Execution timed out 2037 ms 2028 KB Time limit exceeded
7 Halted 0 ms 0 KB -