QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#761480#5417. Chat ProgramMocic1WA 48ms6796kbC++141.6kb2024-11-18 23:31:532024-11-18 23:31:53

Judging History

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

  • [2024-11-18 23:31:53]
  • 评测
  • 测评结果:WA
  • 用时:48ms
  • 内存:6796kb
  • [2024-11-18 23:31:53]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

#define ios ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define int long long
#define pb push_back
#define ff first
#define ss second
typedef pair<int, int> PII;
const int N = 1000005;
const int inf = 1e18;
const int mod = 1e9+7;
mt19937_64 rng(time(0));

int n,k,m,c,d;
int a[N];
bool check(int x){
    vector<int>v(n+5,0);
    int sum=0;
    for(int i=1;i<=n;i++){
        if(a[i]>=x){
            sum++;
        }
        else{
            int cnt=x-a[i]-c;
            cnt=max(cnt,0LL);
            if(d==0){
                if(cnt==0){
                    int rr=i-cnt;
                    int ll=max(1LL,i-m+1);
                    v[ll]++;
                    v[rr+1]--;
                }
                continue;
            }
            int need=cnt/d;
            if(cnt%d)need++;
            if(need>m-1||i-cnt<1)continue;
            else{
                int rr=i-cnt;
                int ll=max(1LL,i-m+1);
                v[ll]++;
                v[rr+1]--;
            }
        }
    }
    for(int i=1;i<=n;i++){
        v[i]=v[i-1]+v[i];
        if(sum+v[i]>=k){
            return 1;
        }
    }
    return 0;
}
void solve() {
    cin>>n>>k>>m>>c>>d;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }

    int l=0,r=1e15;
    while(l<r){
        int mid=l+r+1>>1;
        if(check(mid)){
            l=mid;
        }
        else{
            r=mid-1;
        }
    }
    cout<<l<<'\n';
}
signed main() {
    ios;
    int _ = 1;
    //cin >> _;
    while (_--) {
        solve();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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

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

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

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:

2000099999

result:

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