QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#718459#5417. Chat ProgramRighttWA 44ms8388kbC++141.5kb2024-11-06 20:34:222024-11-06 20:34:23

Judging History

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

  • [2024-11-06 20:34:23]
  • 评测
  • 测评结果:WA
  • 用时:44ms
  • 内存:8388kb
  • [2024-11-06 20:34:22]
  • 提交

answer

#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;
using ll = long long;

const int N = 2e5 + 10;

ll n, k, m, c, d;
ll a[N], b[N], p[N];

bool check(ll x){
    //难写!
    //预处理<x的时刻
    for (int i = 0; i < n; i ++ ) p[i] = 0;
    int res = 0;
    for (int i = 0; i < n; i ++ ){
        if (a[i] >= x){
            res ++;
            continue;
        }
        //
        if (a[i] + (m - 1) * d + c < x) continue;
        //存在<x的时刻
        if (d == 0){
            if (c + a[i] >= x){
                int z = i - m + 1;
                if (z < 0) continue;
                p[z] ++;
            }
            continue;
        }
        int y = (x - a[i] - c + d - 1) / d;//加y次到达X
        int z = i - m + 1 + y;
        if (z < 0) continue;
        p[z] ++;//使得 >= x
    }
    for (int i = 0; i < m; i ++ ) if (a[i] < x && a[i] + c + d * i >= x) res ++;
    if (res >= k) return true;
    for (int i = 1; i + m - 1 < n; i ++ ){
        res -= p[i-1];
        res += p[i];
        if (res >= k) return true;
    }
    return false;
}

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

    ll l = 0, r = 1e9 * (2e5 + 10);
    while (l < r){
        ll mid = (l + r + 1) / 2;
        if (check(mid)) l = mid;
        else r = mid - 1;
    }
    cout << l;
}

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

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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

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

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: 43ms
memory: 8300kb

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: 42ms
memory: 8132kb

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

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: 44ms
memory: 8388kb

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:

964186589

result:

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