#include<bits/stdc++.h>
using namespace std;
struct node{
	int score;
	int id;
}a[105];
struct STU{
	string s;
	int sum;
}stu[105];
int main() {
	int n,m;
	cin >> n >> m;
	for(int i=0;i<m;i++){
		cin >> a[i].score;
		a[i].id = i;
	}
	int maxs = 0;
	for(int i=0;i<n;i++){
		cin >> stu[i].s;
		stu[i].sum=i+1;
		for(int j=0;j<m;j++){
			stu[i].sum += (stu[i].s[j]=='o')*a[j].score;
		}
//		cout << stu[i].sum << " \n";
		maxs=max(maxs,stu[i].sum);
	}
//	cout << "\nmaxs: "<< maxs<<"\n";
	sort(a,a+m,[](const node &x,const node &y){return x.score>y.score;	});
	for(int i=0;i<n;i++){
		if(stu[i].sum==maxs){
			cout << 0 << endl;
			continue;
		}
		int cnt = 0;
		for(int j=0;j<m;j++){
			if(stu[i].s[a[j].id]=='x'){
				stu[i].sum += a[j].score;
				cnt++;
			}
			if(stu[i].sum > maxs){
				cout << cnt << endl;
				break;
			}			
		}
	}
	
	return 0;
}

0 comments

No comments so far...

Information

ID
2196
Time
1000ms
Memory
256MiB
Difficulty
10
Tags
(None)
# Submissions
10
Accepted
3
Uploaded By