Submission #52061

#TimeUsernameProblemLanguageResultExecution timeMemory
52061someone_aaPopeala (CEOI16_popeala)C++17
0 / 100
253 ms78924 KiB
#include <bits/stdc++.h> #define ll long long #define pb push_back #define mp make_pair using namespace std; const int maxn = 4100; int cnt[maxn][maxn], n, t, s; int pref[55][maxn]; int points[maxn]; int prefpoints[maxn]; int dp[maxn][maxn]; bool matrix[maxn][maxn]; /* n - contestants t - test cases s - subtasks */ int main() { cin>>n>>t>>s; for(int i=1;i<=t;i++) { cin>>points[i]; prefpoints[i] = prefpoints[i-1] + points[i]; } string code; for(int i=0;i<n;i++) { cin>>code; for(int j=1;j<=t;j++) { pref[i][j] = pref[i][j-1] + int(code[j-1]-'0'); } } for(int i=1;i<=t;i++) { for(int j=1;j<=i;j++) { for(int k=0;k<n;k++) { if(pref[k][i] - pref[k][j-1] == (i-j+1)) { cnt[j][i]++; } } } } memset(dp, -1, sizeof(dp)); dp[0][0] = 0; for(int j=1;j<=t;j++) { for(int i=1;i<=s;i++) { dp[i][j] = INT_MAX; for(int x=0;x<i;x++) { if(dp[x][j-1] != -1) { dp[i][j] = min(dp[i][j], dp[x][j-1] + (prefpoints[i] - prefpoints[x]) * cnt[x+1][i]); } } if(dp[i][j] == INT_MAX) dp[i][j] = -1; } } for(int i=1;i<=s;i++) { cout<<dp[t][i]<<"\n"; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...