Submission #874890

#TimeUsernameProblemLanguageResultExecution timeMemory
874890Faisal_SaqibPopeala (CEOI16_popeala)C++17
17 / 100
634 ms262144 KiB
#include <iostream> #include <vector> #include <algorithm> using namespace std; const int T=2e4+10; const int N=52; const int inf=2e9+1; int points[1]; string results[1]; int pre[T]; int ptr[N]; vector<int> zero[N]; int zeros[T][T]; int dp[T][N]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n,t,s; cin>>n>>t>>s; for(int i=0;i<t;i++) { cin>>points[0]; pre[i+1]=pre[i]+points[0]; } for(int i=0;i<n;i++) { cin>>results[0]; ptr[i]=0; for(int j=0;j<t;j++) if(results[0][j]=='0') zero[i].push_back(j); } for(int i=0;i<=t;i++) for(int j=0;j<=s;j++) dp[i][j]=inf; dp[0][0]=0; for(int l=1;l<=t;l++) { for(int r=l;r<=t;r++) { zeros[l][r]=n; for(int i=0;i<n;i++) { while(ptr[i]<zero[i].size() and zero[i][ptr[i]]<(l-1)) ptr[i]++; if(ptr[i]<zero[i].size() and zero[i][ptr[i]] < r) zeros[l][r]--; } } } for(int i=0;i<t;i++) { for(int j=0;j<s;j++) { if(dp[i][j]==inf) continue; for(int new_i=i+1;new_i<=t;new_i++) { dp[new_i][j+1]=min(dp[new_i][j+1],dp[i][j]+(pre[new_i]-pre[i])*zeros[i+1][new_i]); } } } for(int j=1;j<=s;j++) cout<<dp[t][j]<<'\n'; return 0; }

Compilation message (stderr)

popeala.cpp: In function 'int main()':
popeala.cpp:46:29: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |                 while(ptr[i]<zero[i].size() and zero[i][ptr[i]]<(l-1))
      |                       ~~~~~~^~~~~~~~~~~~~~~
popeala.cpp:48:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |                 if(ptr[i]<zero[i].size() and zero[i][ptr[i]] < r)
      |                    ~~~~~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...