QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#188089 | #2346. Miniature Golf | jrjyy | AC ✓ | 732ms | 4024kb | C++20 | 1.7kb | 2023-09-25 13:47:43 | 2023-09-25 13:47:43 |
Judging History
answer
#include <bits/stdc++.h>
using i64 = long long;
int main() {
std::cin.tie(nullptr)->sync_with_stdio(false);
int n, m;
std::cin >> n >> m;
std::vector a(n, std::vector<int>(m));
for (int i = 0; i < n; ++i) {
for (int j = 0; j < m; ++j) {
std::cin >> a[i][j];
}
std::sort(a[i].begin(), a[i].end());
a[i].push_back(2e9);
}
auto work = [&](int x) {
std::vector<std::pair<int, int>> s;
for (int y = 0; y < n; ++y) {
if (y != x) {
int i = 0, j = 0, k = 0;
i64 f = 0, g = 0;
while (i < m || j < m) {
int nk = std::min(a[x][i], a[y][j]);
i64 nf = f + 1ll * (m - i) * (nk - k);
i64 ng = g + 1ll * (m - j) * (nk - k);
if (f < g && nf >= ng) {
s.emplace_back((g - f - 1) / (j - i) + 1 + k, -1);
} else if (f >= g && nf < ng) {
s.emplace_back((f - g) / (i - j) + 1 + k, 1);
}
k = nk;
f = nf;
g = ng;
while (a[x][i] == nk) {
++i;
}
while (a[y][j] == nk) {
++j;
}
}
}
}
std::sort(s.begin(), s.end());
int sum = n, ans = n;
for (auto [p, x] : s) {
sum -= x;
ans = std::min(ans, sum);
}
return ans;
};
for (int i = 0; i < n; ++i) {
std::cout << work(i) << "\n";
}
return 0;
}
Details
Test #1:
score: 100
Accepted
time: 1ms
memory: 3508kb
Test #2:
score: 0
Accepted
time: 0ms
memory: 3448kb
Test #3:
score: 0
Accepted
time: 1ms
memory: 3520kb
Test #4:
score: 0
Accepted
time: 0ms
memory: 3464kb
Test #5:
score: 0
Accepted
time: 0ms
memory: 3516kb
Test #6:
score: 0
Accepted
time: 0ms
memory: 3500kb
Test #7:
score: 0
Accepted
time: 0ms
memory: 3484kb
Test #8:
score: 0
Accepted
time: 1ms
memory: 3460kb
Test #9:
score: 0
Accepted
time: 1ms
memory: 3488kb
Test #10:
score: 0
Accepted
time: 0ms
memory: 3540kb
Test #11:
score: 0
Accepted
time: 1ms
memory: 3516kb
Test #12:
score: 0
Accepted
time: 2ms
memory: 3528kb
Test #13:
score: 0
Accepted
time: 0ms
memory: 3512kb
Test #14:
score: 0
Accepted
time: 1ms
memory: 3456kb
Test #15:
score: 0
Accepted
time: 2ms
memory: 3496kb
Test #16:
score: 0
Accepted
time: 11ms
memory: 3740kb
Test #17:
score: 0
Accepted
time: 732ms
memory: 3956kb
Test #18:
score: 0
Accepted
time: 722ms
memory: 3856kb
Test #19:
score: 0
Accepted
time: 606ms
memory: 3916kb
Test #20:
score: 0
Accepted
time: 244ms
memory: 3996kb
Test #21:
score: 0
Accepted
time: 242ms
memory: 3988kb
Test #22:
score: 0
Accepted
time: 242ms
memory: 4024kb
Test #23:
score: 0
Accepted
time: 130ms
memory: 3720kb
Test #24:
score: 0
Accepted
time: 130ms
memory: 3684kb
Test #25:
score: 0
Accepted
time: 128ms
memory: 3680kb
Test #26:
score: 0
Accepted
time: 125ms
memory: 3708kb
Test #27:
score: 0
Accepted
time: 128ms
memory: 3712kb