Submission #609534

# Submission time Handle Problem Language Result Execution time Memory
609534 2022-07-27T16:56:02 Z UncoolAnon Popeala (CEOI16_popeala) C++14
0 / 100
174 ms 2144 KB
#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)); 
	dp[0][0]=0; 
	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&x:pl) cnt+=(x==-1) ; 
			if(testcase) dp[subs][testcase]=dp[subs-1][testcase-1]+v[testcase]*n; 
			else if(subs==1) dp[subs][testcase]=v[testcase]*n;
			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

popeala.cpp: In function 'int main()':
popeala.cpp:36: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]
   36 |    for(int i=0;i<pl.size();i++){
      |                ~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 39 ms 724 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 174 ms 2144 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -