Submission #609920

#TimeUsernameProblemLanguageResultExecution timeMemory
609920HappyPacManPopeala (CEOI16_popeala)C++14
100 / 100
491 ms15292 KiB
#include <bits/stdc++.h> using namespace std; const int inf = 2e9+1; int dp[51][20001],prefix[51][20001]; int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); int N,T,S; cin >> N >> T >> S; int Points[T+1]; for(int i=1;i<=T;i++){ cin >> Points[i]; Points[i] += Points[i-1]; } vector<int> inv[N+1]; for(int i=1;i<=N;i++){ string Results; cin >> Results; for(int j=0;j<T;j++){ if(Results[j] == '0'){ inv[i].emplace_back(j+1); } } reverse(inv[i].begin(),inv[i].end()); } vector<int> check[T+1]; for(int i=1;i<=T;i++){ check[i].emplace_back(i); for(int j=1;j<=N;j++){ if(!inv[j].empty()){ check[i].emplace_back(inv[j].back()); } } sort(check[i].begin(),check[i].end()); for(int j=1;j<=N;j++){ if(!inv[j].empty() && inv[j].back() == i){ inv[j].pop_back(); } } } for(int i=0;i<=S;i++){ for(int j=0;j<=T;j++){ dp[i][j] = inf; } } dp[0][0] = 0; for(int i=1;i<=S;i++){ for(int j=0;j<=N;j++){ for(int k=0;k<=T;k++){ prefix[j][k] = inf; } } for(int j=i;j<=T;j++){ for(int k=0;k<check[j].size();k++){ prefix[N-k][check[j][k]] = min(prefix[N-k][check[j][k]],dp[i-1][j-1]+(N-k)*(Points[check[j][k]]-Points[j-1])); } } for(int j=0;j<=N;j++){ for(int k=1;k<=T;k++){ if(prefix[j][k-1] != inf){ prefix[j][k] = min(prefix[j][k],prefix[j][k-1]+j*(Points[k]-Points[k-1])); } } for(int k=0;k<=T;k++){ dp[i][k] = min(dp[i][k],prefix[j][k]); } } } for(int i=1;i<=S;i++){ cout << dp[i][T] << "\n"; } }

Compilation message (stderr)

popeala.cpp: In function 'int main()':
popeala.cpp:56:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   56 |    for(int k=0;k<check[j].size();k++){
      |                ~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...