Submission #1018279

#TimeUsernameProblemLanguageResultExecution timeMemory
1018279VMaksimoski008Popeala (CEOI16_popeala)C++17
26 / 100
2057 ms11868 KiB
#include <bits/stdc++.h> #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() //#define int long long using namespace std; using ll = long long; using pii = pair<int, int>; using pll = pair<ll, ll>; const int mod = 1e9 + 7; const int LOG = 20; const int maxn = 1e5 + 5; int mat[51][20005]; ll dp[51][20005]; signed main() { ios_base::sync_with_stdio(false); cout.tie(0); cin.tie(0); int n, t, s; cin >> n >> t >> s; vector<int> p(t+1); for(int i=1; i<=t; i++) cin >> p[i]; for(int i=1; i<=n; i++) { for(int j=1; j<=t; j++) { char ch; cin >> ch; mat[i][j] = (ch == '1'); } } for(int i=0; i<=s; i++) for(int j=0; j<=t; j++) dp[i][j] = 1e18; dp[0][0] = 0; for(int j=1; j<=s; j++) { vector<int> last(n+1), rem(t+1); for(int i=1; i<=t; i++) { for(int k=1; k<=n; k++) { if(!mat[k][i]) { rem[last[k]]--; last[k] = i; rem[last[k]]++; } } ll sum = 0, cnt = n; for(int k=i; k>=1; k--) { sum += p[k]; cnt -= rem[k]; dp[j][i] = min(dp[j][i], dp[j-1][k-1] + sum * cnt); } } } for(int i=1; i<=s; i++) cout << dp[i][t] << '\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...