Submission #148075

#TimeUsernameProblemLanguageResultExecution timeMemory
148075WhipppedCreamPopeala (CEOI16_popeala)C++17
100 / 100
376 ms16632 KiB
#include <bits/stdc++.h> #pragma GCC optimize ("O3") #pragma GCC target ("sse4") using namespace std; #define X first #define Y second #define pb push_back typedef pair<int, int> ii; typedef long long ll; const int maxt = 2e4+5; const int maxn = 55; ll pts[maxt]; char foo[maxn][maxt]; int n, t, s; vector<int> lims[maxt]; ll mem[maxt]; ll dp[maxn][maxt]; void clear() { for(int i = 0; i<= n; i++) mem[i] = 1e18+5; } int main() { scanf("%d %d %d", &n, &t, &s); for(int i = 1; i<= t; i++) { scanf("%lld", &pts[i]); pts[i] += pts[i-1]; } for(int i = 1; i<= n; i++) { scanf("%s", foo[i]+1); } for(int i = 1; i<= n; i++) { int last = 0; for(int j = 1; j<= t; j++) { if(foo[i][j] == '1') { lims[j].pb(last); } else { lims[j].pb(j); last = j; } } } for(int i = 1; i<= t; i++) { lims[i].pb(i); sort(lims[i].begin(), lims[i].end()); } for(int i = 0; i<= s; i++) { for(int j = 0; j<= t; j++) { dp[i][j] = 1e18; } } dp[0][0] = 0; for(int i = 1; i<= s; i++) { clear(); for(int j = 1; j<= t; j++) { // printf("computing %d\n", j); for(int k = 0; k<= n; k++) { for(int run = j>1?lims[j-1][k]:0; run< lims[j][k]; run++) { mem[k] = min(mem[k], dp[i-1][run]-pts[run]*k); // if(k == 0) printf("cand2 %d-%d\n", dp[i-1][run], pts[run]*k); } // printf("[%d..%d), %d\n", j>1?lims[j-1][k]:0, lims[j][k], mem[k]); if(lims[j][k]> 0) dp[i][j] = min(dp[i][j], mem[k]+k*pts[j]); // printf("cand %d\n", mem[k]+k*pts[j]); } // printf("dp[%d][%d] = %d\n", i, j, dp[i][j]); } printf("%lld\n", dp[i][t]); } }

Compilation message (stderr)

popeala.cpp: In function 'int main()':
popeala.cpp:30:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d %d", &n, &t, &s);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
popeala.cpp:33:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld", &pts[i]);
   ~~~~~^~~~~~~~~~~~~~~~~
popeala.cpp:38:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%s", foo[i]+1);
   ~~~~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...