QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#90074#5653. Library gamezghtyarecrenjWA 2ms3428kbC++141.5kb2023-03-22 10:10:242023-03-22 10:10:25

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-03-22 10:10:25]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3428kb
  • [2023-03-22 10:10:24]
  • 提交

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]