Submission #740449

#TimeUsernameProblemLanguageResultExecution timeMemory
740449Ahmed57Popeala (CEOI16_popeala)C++17
0 / 100
37 ms1284 KiB
#pragma GCC optimize("Ofast") #include <bits/stdc++.h> using namespace std; int main(){ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); int n,t,s;cin>>n>>t>>s; vector<string>r(n+1); int 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]; int 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); } int dp[s+1][t+1]; memset(dp, 0x3f, sizeof(dp)); dp[0][0] = 0; for(int i = 1;i<=s;i++){ for(int j = 1;j<=t;j++){ for(int k = 0;k<=n;k++){ int val = 0x3f; for(int l=a[j-1][k]; l<a[j][k]; ++l) val=min(dp[i-1][l]-p[l]*k,val); dp[i][j]=min(val+p[j]*k,dp[i][j]); } } cout<<dp[i][t]<<"\n"; } } //
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...