QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#761493 | #5417. Chat Program | Mocic1 | RE | 0ms | 3668kb | C++14 | 1.6kb | 2024-11-18 23:39:59 | 2024-11-18 23:40:00 |
Judging History
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-need<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=1e17;
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;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3652kb
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: 3656kb
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: 3668kb
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: -100
Runtime Error
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 ...