QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#674619#5417. Chat Programyumingsk#RE 51ms6820kbC++202.0kb2024-10-25 16:55:062024-10-25 16:55:06

Judging History

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

  • [2024-10-25 16:55:06]
  • 评测
  • 测评结果:RE
  • 用时:51ms
  • 内存:6820kb
  • [2024-10-25 16:55:06]
  • 提交

answer

#pragma GCC optimize(3, "Ofast", "inline")
#include <iostream>
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define INF 0x3f3f3f3f
#define L_INF 0x7f3f3f3f3f3f3f3f
#define db cout << "debug\n";

using namespace std;
const int Mod = 998244353;
using ll = long long;
#define int long long
int n, k, m, c, d;
int a[200005];
int check(ll mid)
{
    vector<int> b(n + 1, 0);
    for (int i = 1; i <= n; i++)
    {
        if (a[i] >= mid)
            b[1]++;
        else
        {
            int pos;
            if (d != 0)
                pos = min(1LL * m, max(0LL, (mid - c - a[i] + d - 1) / d));
            else
            {
                if (a[i] + c >= mid)
                {
                    b[i]++;
                    b[i + 1]--;
                }
                continue;
            }
            int l = max(0LL, i - m + 1);
            int r = max(0LL, i - pos);
            b[l]++;
            // cout << i << ' ' << l << ' ' << r << " " << pos << '\n';

            b[r + 1]--;
        }
    }
    for (int i = 1; i <= n; i++)
    {
        b[i] += b[i - 1];
        if (b[i] >= k)
            return 1;
    }
    return 0;
}
void solve()
{
    cin >> n >> k >> m >> c >> d;
    for (int i = 1; i <= n; i++)
        cin >> a[i];
    ll l = 0;
    ll r = 1e18;
    // cout << check(5) << '\n';
    while (l <= r)
    {
        ll mid = l + r >> 1;
        // cout << l << ' ' << r << '\n';
        if (check(mid))
        {
            l = mid + 1;
        }
        else
        {
            r = mid - 1;
        }
    }
    cout << l - 1 << '\n';
}
signed main()
{
    IOS;
// freopen("in.txt", "r", stdin);
// freopen("out.txt", "w", stdout);
#ifndef ONLINE_JUDGE
    clock_t start_time = clock();
#endif
    int t = 1;
    // cin >> t;
    while (t--)
    {
        solve();
    }
#ifndef ONLINE_JUDGE
    cout << "Used " << (double)(clock() - start_time) << " ms" << endl;
#endif
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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

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

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

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: 51ms
memory: 6804kb

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: 48ms
memory: 6676kb

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: