Submission #97521

#TimeUsernameProblemLanguageResultExecution timeMemory
97521popovicirobertPopeala (CEOI16_popeala)C++14
100 / 100
523 ms28700 KiB
#include <bits/stdc++.h> #define lsb(x) (x & (-x)) #define ll long long #define ull unsigned long long #define ld long double // 217 // 44 using namespace std; const ll INF = 1e15; const int MAXN = 50; const int MAXT = 20000; int pts[MAXT + 1], sp[MAXT + 1]; char res[MAXN + 1][MAXT + 1]; int ind[MAXN + 1][MAXT + 1]; ll dp[2][MAXT + 1]; ll mn[2][MAXN + 1][MAXT + 1]; int main() { //ifstream cin("A.in"); //ofstream cout("A.out"); int i, j, n, t, s; ios::sync_with_stdio(false); cin.tie(0), cout.tie(0); cin >> n >> t >> s; for(i = 1; i <= t; i++) { cin >> pts[i]; sp[i] = sp[i - 1] + pts[i]; } for(i = 1; i <= n; i++) { cin >> res[i] + 1; for(j = 1; j <= t; j++) { res[i][j] -= '0'; if(res[i][j] == 0) { ind[i][j] = j; } else { ind[i][j] = ind[i][j - 1]; } } } vector < vector <int> > pos(t + 1); for(i = 1; i <= t; i++) { for(j = 1; j <= n; j++) { pos[i].push_back(ind[j][i]); } sort(pos[i].begin(), pos[i].end()); pos[i].push_back(i); } dp[0][0] = 0; for(j = 1; j <= t; j++) { dp[0][j] = INF; } for(int k = 1; k <= s; k++) { for(i = 0; i <= n; i++) { mn[1 - k & 1][i][0] = dp[1 - k & 1][0]; for(j = 1; j <= t; j++) { mn[1 - k & 1][i][j] = min(mn[1 - k & 1][i][j - 1], dp[1 - k & 1][j] - sp[j] * i); } } dp[k & 1][0] = INF; for(j = 1; j <= t; j++) { dp[k & 1][j] = INF; for(i = 0; i < pos[j].size(); i++) { if(pos[j][i] > 0) { dp[k & 1][j] = min(dp[k & 1][j], mn[1 - k & 1][i][pos[j][i] - 1] + sp[j] * i); //cerr << pos[j][i] << " "; } } //cerr << " "; //cerr << dp[k & 1][j] << " "; } //cerr << "\n"; cout << dp[k & 1][t] << "\n"; } //cin.close(); //cout.close(); return 0; }

Compilation message (stderr)

popeala.cpp: In function 'int main()':
popeala.cpp:34:23: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
         cin >> res[i] + 1;
                ~~~~~~~^~~
popeala.cpp:59:18: warning: suggest parentheses around '-' in operand of '&' [-Wparentheses]
             mn[1 - k & 1][i][0] = dp[1 - k & 1][0];
                ~~^~~
popeala.cpp:59:40: warning: suggest parentheses around '-' in operand of '&' [-Wparentheses]
             mn[1 - k & 1][i][0] = dp[1 - k & 1][0];
                                      ~~^~~
popeala.cpp:61:22: warning: suggest parentheses around '-' in operand of '&' [-Wparentheses]
                 mn[1 - k & 1][i][j] = min(mn[1 - k & 1][i][j - 1], dp[1 - k & 1][j] - sp[j] * i);
                    ~~^~~
popeala.cpp:61:48: warning: suggest parentheses around '-' in operand of '&' [-Wparentheses]
                 mn[1 - k & 1][i][j] = min(mn[1 - k & 1][i][j - 1], dp[1 - k & 1][j] - sp[j] * i);
                                              ~~^~~
popeala.cpp:61:73: warning: suggest parentheses around '-' in operand of '&' [-Wparentheses]
                 mn[1 - k & 1][i][j] = min(mn[1 - k & 1][i][j - 1], dp[1 - k & 1][j] - sp[j] * i);
                                                                       ~~^~~
popeala.cpp:67:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for(i = 0; i < pos[j].size(); i++) {
                        ~~^~~~~~~~~~~~~~~
popeala.cpp:69:59: warning: suggest parentheses around '-' in operand of '&' [-Wparentheses]
                     dp[k & 1][j] = min(dp[k & 1][j], mn[1 - k & 1][i][pos[j][i] - 1] + sp[j] * 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...