QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#90074 | #5653. Library game | zghtyarecrenj | WA | 2ms | 3428kb | C++14 | 1.5kb | 2023-03-22 10:10:24 | 2023-03-22 10:10:25 |
Judging History
answer
#include <bits/stdc++.h>
const int N = 5005;
int n, m, a[N];
int main() {
std::ios::sync_with_stdio(false);
std::cin >> n >> m;
for (int i = 1; i <= n; ++i) std::cin >> a[i];
std::sort(a + 1, a + 1 + n, std::greater<int>());
int flg = 0;
for (int i = 1; i <= n; ++i)
if (a[i] > m / i) { flg = i; break; }
std::set<int> used;
used.insert(m + 1);
if (flg) { // B
std::cout << "Bernardo" << std::endl;
for (int i = 1; i <= n; ++i) {
int y, x; std::cin >> y >> x;
int fd = -1;
auto fy = used.lower_bound(y), fx = used.lower_bound(x);
if (fy != fx || *fy == y)
std::cout << *fx << std::endl;
else {
int pos = ((x + a[flg] - 1) / a[flg]) * a[flg];
if (pos <= x + y - 1) used.insert(pos), std::cout << pos << std::endl;
else used.insert(x), std::cout << x << std::endl;
}
}
} else { // A
std::cout << "Alessia" << std::endl;
for (int i = 1; i <= n; ++i) {
int lst = 0, res = -1;
for (int x : used) {
if (x - lst - 1 >= a[i]) {
res = lst + 1;
break;
}
lst = x;
}
std::cout << a[i] << ' ' << res << std::endl;
int x; std::cin >> x;
used.insert(x);
}
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3344kb
input:
5 14 3 7 2 3 10 7 14 2 4 6
output:
Alessia 10 1 7 8 3 1 3 3 2 5
result:
ok Contestant won the game
Test #2:
score: -100
Wrong Answer
time: 2ms
memory: 3428kb
input:
4 10 4 1 6 4 6 1 4 5
output:
Bernardo 4 11
result:
wrong answer Integer 11 violates the range [5, 8]