QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#672063#5417. Chat ProgramyellWA 52ms5544kbC++201.5kb2024-10-24 15:29:482024-10-24 15:29:49

Judging History

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

  • [2024-10-24 15:29:49]
  • 评测
  • 测评结果:WA
  • 用时:52ms
  • 内存:5544kb
  • [2024-10-24 15:29:48]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
using LL = long long;

void solve() {
    int n, k, m, c, d;
    cin >> n >> k >> m >> c >> d;
    vector<int> a(n + 1);
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }

    auto check = [&](LL mid) -> bool {
        vector<LL> b(n + 2);
        LL cnt = 0;
        for (int i = 1; i <= n; i++) {
            b[i] = (a[i] >= mid);
            cnt += (a[i] >= mid);
        }
        if (cnt >= k) {
            return true;
        }
        for (int i = 1; i <= n; i++) {
            if (a[i] >= mid) continue;
            if (a[i] + c + 1LL * d * (m - 1) < mid) continue;
            b[i]++;
            if (d == 0) {
                b[min(n + 1, i + m)]--;
            } else {
                LL x = (mid - a[i] - c) / d;
                LL r = max(1LL, 1LL * i + m - 1 - x);
                r = min(1LL * n + 1, r);
                b[r]--;
            }
        }

        for (int i = 1; i <= n; i++) {
            b[i] += b[i - 1];
            if (b[i] + cnt >= k) {
                return true;
            }
        }
        return false;
    };

    LL l = 0, r = 1e18;
    while (l < r) {
        LL mid = (l + r + 1) / 2;
        if (check(mid)) {
            l = mid;
        } else {
            r = mid - 1;
        }
    }
    cout << l << "\n";
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
    // cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3524kb

input:

6 4 3 1 2
1 1 4 5 1 4

output:

4

result:

ok 1 number(s): "4"

Test #2:

score: 0
Accepted
time: 0ms
memory: 3532kb

input:

7 3 2 4 0
1 9 1 9 8 1 0

output:

9

result:

ok 1 number(s): "9"

Test #3:

score: 0
Accepted
time: 0ms
memory: 3548kb

input:

8 3 5 0 0
2 0 2 2 1 2 1 8

output:

2

result:

ok 1 number(s): "2"

Test #4:

score: 0
Accepted
time: 52ms
memory: 5544kb

input:

200000 200000 100000 0 1000000000
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

output:

0

result:

ok 1 number(s): "0"

Test #5:

score: -100
Wrong Answer
time: 48ms
memory: 5432kb

input:

200000 1 100000 1000000000 1000000000
1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 100000000...

output:

100000999999999

result:

wrong answer 1st numbers differ - expected: '100001000000000', found: '100000999999999'