Submission #698085

#TimeUsernameProblemLanguageResultExecution timeMemory
698085abcvuitunggioPopeala (CEOI16_popeala)C++17
17 / 100
2072 ms9428 KiB
#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'; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...