Submission #609909

# Submission time Handle Problem Language Result Execution time Memory
609909 2022-07-28T03:10:00 Z chirathnirodha Popeala (CEOI16_popeala) C++17
0 / 100
49 ms 1532 KB
//Coded by Chirath Nirodha
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define P push
#define I insert
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
const string abc="abcdefghijklmnopqrstuvwxyz";
const string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
const ll mod=1e9+7;
const ll inf=1000000000000;
inline void io(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
}

void solve(){
    io();
	ll n,t,s;cin>>n>>t>>s;
	ll p[t+1];p[0]=0;
	int len[t+1][n+1];
	for(int i=1;i<=t;i++){
		cin>>p[i];
		p[i]+=p[i-1];
	}
	
	for(int i=0;i<n;i++){
		string str;cin>>str;
		for(int j=0;j<t;j++){
			if(str[j]=='0')len[j+1][i]=j;
			else len[j+1][i]=len[j][i];
		}
	}
	for(int i=1;i<=t;i++){
		len[i][0]=i;
		sort(len[i],len[i]+n);
	}
	ll dp[t+1][s+1];
	for(int i=0;i<t;i++)for(int j=0;j<s;j++)dp[i][j]=inf;
	ll best[n+1];
	for(int i=1;i<=s;i++){
		for(int j=0;j<=n;j++)best[j]=inf;
		for(int j=1;j<=t;j++){
			for(ll k=0;k<=n;k++){
				for(int l=len[j-1][k];l<len[j][k];l++)
					best[k] = min(best[k], dp[l][i - 1] - p[l] * k);
				dp[j][i]=min(dp[j][i],best[k]+p[j]*k);
			}
		}
		cout<<dp[t][i]<<endl;
	}
}
int main(){
    io();
	solve();
	//int t;cin>>t;for(int i=0;i<t;i++)solve();
    return 0;
}
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 340 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 980 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 49 ms 1532 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 340 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -