Submission #608743

# Submission time Handle Problem Language Result Execution time Memory
608743 2022-07-27T09:49:58 Z CSQ31 Popeala (CEOI16_popeala) C++17
0 / 100
321 ms 484 KB
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e4+1;
#define owo ios_base::sync_with_stdio(0);cin.tie(0);
typedef long long int ll;
int pt[MAXN],n,t,s;
string stu[50];
ll dp1[MAXN],dp2[MAXN],mx[2*MAXN],lazy[2*MAXN];
int last[50];
void tran(){
	for(int i=0;i<n;i++)last[i] = 0;
	for(int i=1;i<=t;i++){
		for(int j=0;j<n;j++){
			if(stu[j][i-1] == '1'){
				for(int k=last[j];k<i;k++)dp1[k]+=pt[i];
				//[last[j],i) gets increased by pt[i]
			}else{
				//reverse the change did
				if(i>1 && stu[j][i-2] == '1'){
					int run = 0;
					for(int k=i-2;k>=last[j];k--){
						run+=pt[k+1];
						dp1[k]-=run;
						
					}
				}
				last[j] = i;
				
			}
		}
		for(int x=0;x<i;x++)dp2[i] = min(dp2[i],dp1[x]);
	}
}
int main(){
	owo
	cin>>n>>t>>s;
	for(int i=1;i<=t;i++)cin>>pt[i];
	for(int i=0;i<n;i++)cin>>stu[i];
	
	vector<int>ans(s+1,0);
	for(int i=0;i<=t;i++)dp2[i] = 2e9;
	for(int i=1;i<=s;i++){
		tran();
		ans[i] = dp2[t];
		for(int j=0;j<=t;j++){
			swap(dp1[j],dp2[j]);
			dp2[j] = 2e9;
		}
	}
	for(int i=1;i<=s;i++)cout<<ans[i]<<'\n';
	
	
}

# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Incorrect 1 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 51 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 321 ms 484 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Incorrect 1 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -