QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#685090#5417. Chat ProgramVegetogWA 58ms8340kbC++201.6kb2024-10-28 17:33:072024-10-28 17:33:08

Judging History

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

  • [2024-10-28 17:33:08]
  • 评测
  • 测评结果:WA
  • 用时:58ms
  • 内存:8340kb
  • [2024-10-28 17:33:07]
  • 提交

answer

#include <bits/stdc++.h>
#ifndef ONLINE_JUDGE
#include "_my_utils.h"
#endif
#define int long long

using namespace std;
using ll = long long;
using PII = std::pair<int, int>;

constexpr ll INF = 2E18 + 10;
constexpr int N = 2E5 + 10;

int n, k, m, c, d;
int a[N];

int b[N];

bool check(int x) {
    for (int i = 1; i <= n; i++) {
        a[i] = b[i];
    }
    vector<int> pr(n + 10, 0);
    for (int i = 1; i <= n; i++) {
        if (a[i] >= x) {
            pr[1]++;
            pr[n + 1]--;
        } else if (a[i] + c + d * (min(i, m) - 1) >= x) {
            if(d==0){
                pr[max(1LL, i - m + 1)]++;
                pr[i + 1]--;
                continue;
            }
            pr[max(1LL, i - m + 1)]++;
            int mx = a[i] + c + d * (min(i, m) - 1);
            int cnt = (mx - x + d - 1) / d;
            pr[max(1LL,i-m+1) + cnt + 1]--;
        }
    }
    int t = 0;
    for (int i = 1; i + m - 1 <= n; i++) {
        t += pr[i];
        if (t >= k) {
            return 1;
        }
    }
    return 0;
}

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

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

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

    int SAMPLES = 1;
    // cin >> SAMPLES;
    for (int CUR = 1; CUR <= SAMPLES; CUR++) {
        SINGLE_TEST();
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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

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

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: 50ms
memory: 8340kb

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: 40ms
memory: 8264kb

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: 38ms
memory: 8268kb

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
Wrong Answer
time: 58ms
memory: 8332kb

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:

964476279

result:

wrong answer 1st numbers differ - expected: '964474978', found: '964476279'