Submission #740434

# Submission time Handle Problem Language Result Execution time Memory
740434 2023-05-12T13:12:24 Z Ahmed57 Popeala (CEOI16_popeala) C++17
26 / 100
2000 ms 8148 KB
#include <bits/stdc++.h>

using namespace std;
int tele[2000005];
int le[2000005];
bool vis[2000005];
int ans = 0;bool ss = 0;
void dfs(int i){
    ans++;vis[i] = 1;
    if(tele[i]==0){ss = 1;return ;}
    if(!vis[tele[i]])dfs(tele[i]);
}
int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    long long n,t,s;cin>>n>>t>>s;
    vector<string>r(n+1);
    long long p[t+1] = {0};for(int i = 1;i<=t;i++)cin>>p[i],p[i]+=p[i-1];
    for(int i = 1;i<=n;i++)cin>>r[i];
    long long a[t+1][n+1];memset(a,0,sizeof a);
    for(int i = 1;i<=t;i++){
        for(int j = 1;j<=n;j++){
            a[i][j] = (r[j][i-1]=='0'?i:a[i-1][j]);
        }
    }
    for(int i = 1;i<=t;i++){
        a[i][0] = i;
        sort(a[i],a[i]+n+1);
    }
    long long dp[s+1][t+1];
    dp[0][0] = 0;
    for(int i = 1;i<=t;i++)dp[0][i] = 1e18;
    for(int i = 1;i<=s;i++){
        dp[i][0] = 1e18;
        for(int j = 1;j<=t;j++){
            dp[i][j] = 1e18;
            for(int k = 0;k<=n;k++){
                long long val = 1e18;
                for(int l = (k==0?0:a[j][k-1]);l<a[j][k];l++){
                    val = min(val,dp[i-1][l]+(k*(p[j]-p[l])));
                }
                dp[i][j] = min(dp[i][j],val);
            }
        }
        cout<<dp[i][t]<<"\n";
    }
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 724 KB Output is correct
2 Correct 11 ms 724 KB Output is correct
3 Correct 12 ms 736 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 161 ms 2164 KB Output is correct
2 Correct 292 ms 3064 KB Output is correct
3 Correct 491 ms 4000 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 12 ms 724 KB Output is correct
4 Correct 11 ms 724 KB Output is correct
5 Correct 12 ms 736 KB Output is correct
6 Correct 161 ms 2164 KB Output is correct
7 Correct 292 ms 3064 KB Output is correct
8 Correct 491 ms 4000 KB Output is correct
9 Correct 1269 ms 6316 KB Output is correct
10 Execution timed out 2055 ms 8148 KB Time limit exceeded
11 Halted 0 ms 0 KB -