Submission #567375

#TimeUsernameProblemLanguageResultExecution timeMemory
567375piOOEPopeala (CEOI16_popeala)C++17
0 / 100
79 ms25348 KiB
#include <bits/stdc++.h> using namespace std; #define all(x) begin(x), end(x) #define sz(x) ((int)size(x)) #define trace(x) cout << #x << ": " << (x) << endl; typedef long long ll; mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); const int S = 50, N = 50, T = 20000; int L[S][T], R[S][T], W[S][T], s, n, t, A[T], dp[S][T]; bool solved[N][T]; int weight(int l, int r) { int every = 0; for (int i = 0; i < n; ++i) { int sum = 0; bool ok = true; for (int j = l; j <= r; ++j) { if (!solved[i][j]) { ok = false; break; } sum += A[j]; } every += ok ? sum : 0; } return every; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cin >> n >> t >> s; for (int i = 0; i < t; ++i) { cin >> A[i]; } for (int i = 0; i < n; ++i) { string ss; cin >> ss; for (int j = 0; j < t; ++j) { solved[i][j] = ss[j] == '1'; } } for (int i = 0; i < t; ++i) { for (int cnt = 0; cnt < s; ++cnt) { dp[i][cnt] = INT_MAX; for (int j = i; j > -1; --j) { if (cnt > j) break; if (j == 0) { dp[i][cnt] = weight(j, i); } else if (cnt && dp[j - 1][cnt - 1] != INT_MAX){ dp[i][cnt] = min(dp[i][cnt], dp[j - 1][cnt - 1]) + weight(j, i); } } if (i == t - 1) { cout << dp[i][cnt] << '\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...