QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#726178#5417. Chat ProgramMoemi_WA 104ms8036kbC++203.3kb2024-11-08 22:09:162024-11-08 22:09:17

Judging History

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

  • [2024-11-08 22:09:17]
  • 评测
  • 测评结果:WA
  • 用时:104ms
  • 内存:8036kb
  • [2024-11-08 22:09:16]
  • 提交

answer

#include <iostream>
#include <cstring>
#include <algorithm>
#include <map>
#include <vector>
#include <set>
#include <queue>
#include <cmath>
#include <stack>
#include <cstring>
#include <iomanip>
#include <unordered_map>
#include <numeric>

#define sc_int(x) scanf("%d", &x)

#define x first
#define y second
#define pb push_back

using namespace std;

const int N = 2e5 + 10, M = 5010, MOD = 1e9 + 7;
const int inf = 1e9;

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
typedef pair<string, int> PSI;
typedef pair<LL, LL> PLL;
typedef pair<double, double> PDD;
typedef pair<char, int> PCI;
typedef pair<string, string> PSS;

LL n, m, k, c, d;

void solve()
{
    cin >> n >> k >> m >> c >> d;

    vector<LL> a(n + 1);
    for(int i = 1; i <= n; i ++) cin >> a[i];

    auto check = [&](LL t)
    {
        vector<LL> cnt(n + 10);
        vector<LL> cnt2(n + 10);
        for(int i = 1; i <= n; i ++) 
        {
            cnt[i] = cnt[i - 1];
            if(a[i] >= t) cnt[i] ++;
        }
        for(int i = 1; i <= m; i ++)
        {
            if(a[i] >= t) cnt2[1] ++;
            else 
            {
                if(a[i] + (i - 1) * d + c < t) 
                {
                    // for(int i = 1; i <= n; i ++) cout << cnt2[i] << " ";
                    // cout << endl;
                    continue; 
                }
                cnt2[1] ++;
                if(a[i] + c >= t) cnt2[i + 1] --;
                else 
                {
                    LL pos = (t - c - a[i]) / d;
                    if((t - c - a[i]) % d == 0) pos --;
                    if(m - pos <= n) cnt2[m - pos] --;
                }
            }
            // for(int i = 1; i <= n; i ++) cout << cnt2[i] << " ";
            // cout << endl;
        }
        LL sum = c + (m - 1) * d;
        for(int i = m + 1; i <= n; i ++)
        {
            if(a[i] >= t) cnt2[i - m + 1] ++;
            else 
            {
                if(a[i] + (i - 1) * d + c < t) 
                {
                    // for(int i = 1; i <= n; i ++) cout << cnt2[i] << " ";
                    // cout << endl;
                    continue; 
                }
                cnt2[i - m + 1] ++;
                if(a[i] + c >= t) cnt2[i + 1] --;
                else 
                {
                    LL pos = (t - c - a[i]) / d;
                    if((t - c - a[i]) % d == 0) pos --;
                    if(i - pos <= n) cnt2[i - pos] --;
                }
            }
            // for(int i = 1; i <= n; i ++) cout << cnt2[i] << " ";
            // cout << endl;
        }

        LL ans = 0;
        for(int i = 1; i + m - 1 <= n; i ++)
        {
            cnt2[i] += cnt2[i - 1];
            ans = max(ans, cnt2[i] + cnt[n] - cnt[i + m - 1]);
        }
        // cout << ans << endl;
        return ans >= k;
    };
    LL l = 0, r = 1e18;
    while(l < r)
    {
        LL mid = l + r + 1 >> 1;
        if(check(mid)) l = mid;
        else r = mid - 1;
    }
    cout << l << endl;
}


int main()
{
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    int T = 1;
    // cin >> T;
    while(T --)
    {
        solve();
    }
}

詳細信息

Test #1:

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

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: 1ms
memory: 3800kb

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: 1ms
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: 67ms
memory: 8036kb

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: 57ms
memory: 7824kb

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

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: 104ms
memory: 7772kb

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:

4051114036744

result:

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