Submission #609538

#TimeUsernameProblemLanguageResultExecution timeMemory
609538UncoolAnonPopeala (CEOI16_popeala)C++14
0 / 100
181 ms2140 KiB
#include <bits/stdc++.h> #define int long long using namespace std; const int inf=3e9; signed main(){ int n,t,s; cin>>n>>t>>s; vector<vector<int>> dp(s+1,vector<int>(t+1,inf)); vector<int> v(t); for(int&x:v) cin>>x; vector<int> prefix=v; for(int i=1;i<t;i++) prefix[i]+=prefix[i-1]; vector<vector<char>> a(n,vector<char>(t)); for(int i=0;i<n;i++) for(int j=0;j<t;j++) cin>>a[i][j]; vector<vector<int>> last(n,vector<int>(t,-1)); for(int i=0;i<n;i++){ for(int j=0;j<t;j++){ if(a[i][j]=='0') last[i][j]=j; else if(j) last[i][j]=last[i][j-1]; } } for(int subs=1;subs<=s;++subs){ for(int testcase=0;testcase<t;testcase++){ vector<int> pl; for(int contestant=0;contestant<n;contestant++) pl.push_back(last[contestant][testcase]); sort(pl.begin(),pl.end()); int cnt=0; for(int contestant=0;contestant<n;contestant++) cnt+=(a[contestant][testcase]=='1'); if(testcase) dp[subs][testcase]=dp[subs-1][testcase-1]+v[testcase]*cnt; else if(subs==1) dp[subs][testcase]=v[testcase]*cnt; for(int i=0;i<pl.size();i++){ if(pl[i]==-1) continue; if(subs==1) dp[subs][testcase]=min(dp[subs][testcase],prefix[testcase]*i); else if(pl[i]) dp[subs][testcase]=min(dp[subs][testcase],dp[subs-1][pl[i]-1]+(prefix[testcase]-prefix[pl[i]-1])*i); } } } for(int i=1;i<=s;i++) cout<<dp[i][t-1]<<endl; return 0; }

Compilation message (stderr)

popeala.cpp: In function 'int main()':
popeala.cpp:35:17: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |    for(int i=0;i<pl.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...