QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#208235 | #5114. Cells Coloring | FYBGC | WA | 0ms | 3660kb | C++20 | 1.1kb | 2023-10-09 11:24:00 | 2023-10-09 11:24:01 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 300;
ll a[N];
ll b[N];
void solve()
{
int n, m, c, d;
cin >> n >> m >> c >> d;
string s[n + 10];
// vector<int> a(n + 1);
// vector<int> b(n + 1);
for (int i = 0; i < n; i++)
cin >> s[i];
for (int i = 0; i < n; i++)
{
for (int j = 0; j < m; j++)
{
if (s[i][j] == '.')
{
a[i]++;
b[j]++;
}
}
}
int k = max(*max_element(a, a + n), *max_element(b, b + m));
int ans = c * k;
for (int i = k - 1; i >= 0; i--)
{
int cnt1 = 0;
for (int j = 0; j < n; j++)
cnt1 += max(0LL, a[j] - i);
int cnt2 = 0;
for (int j = 0; j < m; j++)
cnt2 += max(0LL, b[j] - i);
ans = min(ans, max(cnt2, cnt1) * d + c * i);
}
cout << ans << endl;
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
int t = 1;
// cin >> t;
while (t--)
{
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3612kb
input:
3 4 2 1 .*** *..* **..
output:
4
result:
ok 1 number(s): "4"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3644kb
input:
3 4 1 2 .*** *..* **..
output:
2
result:
ok 1 number(s): "2"
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 3660kb
input:
250 250 965680874 9042302 ..**.*****..**..**.*****..***..***.**......*.***.*...***.*....*.**.*.**.*.*.****...*.******.***.************....**.*..*..***.*******.*.***.*..**..****.**.*.*..***.****..**.....***.....*.****...*...*.***..****..**.*.*******..*.*******.*.*.*.****.*.*** ....**.*******.*.******...
output:
-2084300836
result:
wrong answer 1st numbers differ - expected: '109972100048', found: '-2084300836'