QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#879850#5417. Chat ProgramHorcrux#RE 39ms6780kbC++231.1kb2025-02-02 16:39:302025-02-02 16:39:30

Judging History

This is the latest submission verdict.

  • [2025-02-02 16:39:30]
  • Judged
  • Verdict: RE
  • Time: 39ms
  • Memory: 6780kb
  • [2025-02-02 16:39:30]
  • Submitted

answer

#include <bits/stdc++.h>
#define int long long

using namespace std;

constexpr int MAXN = 200005;
int n, k, m, c, d, a[MAXN];

bool check(int x) {
    vector <int> pre(n + 1, 0);
    for(int i = 1; i <= n; i++) {
        if(a[i] >= x) {
            pre[1]++;
        } else if(a[i] + c + min(m - 1, i - 1) * d >= x) {
            pre[max(1ll, i - m + 1)]++;
            int cnt = 0;
            if(d != 0) {
                cnt = (x - a[i] - c + d - 1) / d;
            }
            pre[min(i, i - cnt) + 1]--;
        }
    }

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

    return false;
}

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

    cin >> n >> k >> m >> c >> d;

    for(int i = 1; i <= n; i++) {
        cin >> a[i];
    }

    int l = 0, r = 4E14;
    while(l < r) {
        int mid = (l + r) / 2;
        if(check(mid)) {
            l = mid + 1;
        } else {
            r = mid;
        }
    }

    cout << r - 1 << '\n';

    return 0;
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 3584kb

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: 3712kb

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: 1ms
memory: 3584kb

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: 39ms
memory: 6736kb

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: 0
Accepted
time: 27ms
memory: 6780kb

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:

100001000000000

result:

ok 1 number(s): "100001000000000"

Test #6:

score: 0
Accepted
time: 23ms
memory: 6752kb

input:

200000 1 200000 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:

200001000000000

result:

ok 1 number(s): "200001000000000"

Test #7:

score: -100
Runtime Error

input:

200000 24420 17993 881138881 700368758
231187558 519018952 260661004 740633836 931672020 155904999 647179942 13217847 779799803 382810661 242588977 708308843 309853544 225488875 389115097 588643904 644409212 704920939 231829287 39891424 881158891 341251089 486868469 808002305 629160633 317239613 771...

output:


result: