[ABC323C] World Tour Finals 模拟
作者:
多米尼克領主的致意
,
2024-05-13 12:43:55
,
所有人可见
,
阅读 2
#include <bits/stdc++.h>
using namespace std;
int n, m;
string s[110];
int sum[110];
bool st[110][110];
int mx = -1, mxcnt;
struct node{
int v, idx;
}a[110];
bool cmp(node a, node b){
return a.v > b.v;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n >> m;
for(int i = 1;i <= m;i++){
cin >> a[i].v;
a[i].idx = i;
}
for(int i = 1;i <= n;i++){
cin >> s[i];
s[i] = '.' + s[i];
sum[i] = i;
for(int j = 1;j <= m;j++){
if(s[i][j] == 'o'){
sum[i] += a[j].v;
st[i][j] = 1;
}
}
// cout << sum[i] << endl;
if(sum[i] == mx)mxcnt++;
else if(sum[i] > mx){
mx = sum[i];
mxcnt = 1;
}
}
// cout << mxcnt << endl;
sort(a + 1, a + 1 + m, cmp);
for(int i = 1;i <= n;i++){
int cnt = 0;
if(mxcnt > 1 && sum[i] == mx){
cout << "1\n";
continue;
}
if(mxcnt == 1 && sum[i] == mx){
cout << "0\n";
continue;
}
for(int j = 1;j <= m;j++){
if(sum[i] > mx)break;
if(!st[i][a[j].idx]){
sum[i] += a[j].v;
cnt++;
}
}
cout << cnt << endl;
}
return 0;
}