QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#691763#5417. Chat ProgramShawk#WA 46ms6784kbC++171.2kb2024-10-31 12:55:352024-10-31 12:55:36

Judging History

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

  • [2024-10-31 12:55:36]
  • 评测
  • 测评结果:WA
  • 用时:46ms
  • 内存:6784kb
  • [2024-10-31 12:55:35]
  • 提交

answer

#include <bits/stdc++.h>
#define test(x) cout << #x <<" = " << x << endl
#define int long long
#define vint vector<int>
#define endl "\n"
using namespace std;
const int N = 2e5 + 5;

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

int Cal(int x) {
    vint b(n + 2);
    for (int i = 1; i <= n; ++i) {
        if (a[i] >= x)
            b[1]++;
        else if (a[i] + min(i, m) * d + c >= x) {
            b[max(1ll, i - m + 1)]++;
            if (!d) {
                b[i+1]--;
            }
            else {
                int tt = (x - a[i] - c - 1) / d + 1;
                b[i-tt+2]--;
            }
        }
    }
    int ans = 0, t = 0;
    for (int i = 1; i <= n; ++i) {
        t += b[i];
        ans = max(ans, t);
    }
    return ans;
}

void sol(){
    cin >> n >> k >> m >> c >> d;
    // vint a(n + 1);
    for (int i = 1; i <= n; ++i)
        cin >> a[i];
    int l = 0, r = 1e18, mid;
    while (l < r) {
        int mid = (l + r + 1) >> 1;
        if (Cal(mid) >= k) l = mid;
        else r = mid - 1;
    }
    cout << l << endl;
}

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int T = 1;
    // cin >> T;
    while(T--) {
        sol();
    }
    return 0;
}
/*

*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
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: 3644kb

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: 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: 46ms
memory: 6784kb

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: 36ms
memory: 6708kb

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:

100002000000000

result:

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