Submission #316754

#TimeUsernameProblemLanguageResultExecution timeMemory
316754ant101Popeala (CEOI16_popeala)C++14
100 / 100
321 ms9704 KiB
#include <bits/stdc++.h> using namespace std; int points[20001], prv[20001][51], best[51], dp[20001][51]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n, t, s; cin >> n >> t >> s; for (int i = 1; i <= t; i++) { cin >> points[i]; points[i] += points[i - 1]; } for (int j = 1; j <= n; j++) { string solved; cin >> solved; for (int i = 0; i < solved.size(); i++) { if (solved[i] == '1') prv[i + 1][j] = prv[i][j]; else prv[i + 1][j] = i + 1; } } for (int i = 1; i <= t; i++) { prv[i][0] = i; sort(prv[i], prv[i] + n + 1); } memset(dp, 0x3f, sizeof dp); dp[0][0] = 0; for (int j = 1; j <= s; j++) { memset(best, 0x3f, sizeof best); for (int i = 1; i <= t; i++) { for (int k = 0; k <= n; k++) { for (int l = prv[i - 1][k]; l < prv[i][k]; l++) { best[k] = min(best[k], dp[l][j - 1] - points[l] * k); } dp[i][j] = min(dp[i][j], best[k] + points[i] * k); } } cout << dp[t][j] << '\n'; } return 0; }

Compilation message (stderr)

popeala.cpp: In function 'int main()':
popeala.cpp:18:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |         for (int i = 0; i < solved.size(); i++) {
      |                         ~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...