QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#718638#5417. Chat ProgramRighttRE 23ms5900kbC++201.3kb2024-11-06 21:01:462024-11-06 21:01:51

Judging History

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

  • [2024-11-06 21:01:51]
  • 评测
  • 测评结果:RE
  • 用时:23ms
  • 内存:5900kb
  • [2024-11-06 21:01:46]
  • 提交

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], p[N];

bool check(ll x){
    //难写!
    //预处理<x的时刻
    for (int i = 0; i < n + m; i ++ ) p[i] = 0;
    int res = 0;
    for (int i = m; i < n + m; i ++ ){
        if (a[i] >= x){
            res ++;
        }else if (a[i] + c + d * (m - 1) >= x){
            int pre;
            if (d == 0 || a[i] + c >= x){
                pre = i + 1;
            }else{
                int y = (x - c - a[i] + d - 1) / d;
                pre = i - y + 1;
            }
            p[pre] ++; //pre时刻去除的贡献
        }
    }
    for (int i = 0; i + m - 1 < n + m; i ++ ){
        res -= p[i];
        if (i+m-1>=m&&a[i+m-1]<x&&a[i+m-1]+c+d*(m-1)>=x) res ++;
        if (i >= m && res >= k) return true;
    }
    return false;
}

void solve(){
    cin >> n >> k >> m >> c >> d;
    for (int i = m; i < n + m; 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: 5600kb

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

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

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: 23ms
memory: 5900kb

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
Runtime Error

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:


result: