Submission #924987

# Submission time Handle Problem Language Result Execution time Memory
924987 2024-02-10T10:13:55 Z JakobZorz Popeala (CEOI16_popeala) C++17
26 / 100
2000 ms 20060 KB
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
#include<limits.h>
#include<math.h>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<iomanip>
#include<cstring>
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using namespace std;
 
int n,t,s;
ll pts[20000];
int done[50][20000];
ll dp[51][20001];
ll cost[51][20001];
 
void solve(){
    cin>>n>>t>>s;
    for(int i=0;i<t;i++)
        cin>>pts[i];
    for(int i=t-2;i>=0;i--)
        pts[i]+=pts[i+1];
    
    for(int i=0;i<n;i++){
        string str;
        cin>>str;
        for(int j=0;j<t;j++){
            if(str[j]=='1'){
                if(j)
                    done[i][j]=done[i][j-1]+1;
                else
                    done[i][j]=1;
            }
        }
    }
    
    for(int i=0;i<51;i++)
        for(int j=0;j<20001;j++)
            dp[i][j]=1e18;
    
    dp[0][0]=0;
    
    for(int num=1;num<=s;num++){
        for(int i=0;i<=t;i++)
            for(int p=0;p<=n;p++)
                cost[p][i]=dp[num-1][i]+pts[i]*p;
        
        for(int i=0;i<=t;i++){
            if(i){
                vector<int>vec;
                vec.push_back(i);
                vec.push_back(0);
                for(int p=0;p<n;p++)
                    vec.push_back(done[p][i-1]);
                sort(vec.begin(),vec.end());
                reverse(vec.begin(),vec.end());
                for(int j=0;j<=n;j++){
                    for(int k=i-vec[j];k<i-vec[j+1];k++){
                        dp[num][i]=min(dp[num][i],cost[j][k]-pts[i]*j);
                    }
                }
            }
            
            /*for(int p=0;p<=n;p++){
                for(int j=i;j>=0;j--){
                    cost[p][j]+=pts[i]*p;
                }
            }*/
        }
    }
    
    for(int i=0;i<s;i++)
        cout<<dp[i+1][t]<<"\n";
}
 
int main(){
    ios::sync_with_stdio(false);cout.tie(NULL);cin.tie(NULL);
    //freopen("input.in","r",stdin);freopen("output.out","w",stdout);
    int t=1;//cin>>t;
    while(t--)solve();
    return 0;
}
 
/*
 
2 3 3
4 3 5
101
110
 
 
0
8
16
 
 */
# Verdict Execution time Memory Grader output
1 Correct 2 ms 12632 KB Output is correct
2 Correct 3 ms 18780 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 38 ms 18264 KB Output is correct
2 Correct 34 ms 19032 KB Output is correct
3 Correct 37 ms 19036 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 257 ms 19248 KB Output is correct
2 Correct 413 ms 19392 KB Output is correct
3 Correct 604 ms 18012 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 12632 KB Output is correct
2 Correct 3 ms 18780 KB Output is correct
3 Correct 38 ms 18264 KB Output is correct
4 Correct 34 ms 19032 KB Output is correct
5 Correct 37 ms 19036 KB Output is correct
6 Correct 257 ms 19248 KB Output is correct
7 Correct 413 ms 19392 KB Output is correct
8 Correct 604 ms 18012 KB Output is correct
9 Correct 1256 ms 19472 KB Output is correct
10 Execution timed out 2043 ms 20060 KB Time limit exceeded
11 Halted 0 ms 0 KB -