QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#693803 | #5417. Chat Program | yaLen | WA | 77ms | 26460kb | C++14 | 1.7kb | 2024-10-31 16:46:36 | 2024-10-31 16:46:39 |
Judging History
answer
#include <bits/stdc++.h>
#define KE ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
using namespace std;
#define int long long
#define flt(x) cout << fixed << setprecision(x);
#define all(x) (x).begin(), (x).end()
#define bcount(t) __builtin_popcount(t)
#define Mod(x,m) (((x) % m + m) % m)
#define flip(x) reverse(x)
#define lowbit(x) (x&(-x))
#define bemax(x,y) x = max(x, y)
#define pb push_back
#define elif else if
#define endl '\n'
#define AA cerr << "AA" << endl;
#define __ << " " <<
const int N = 1e6 + 10;
const int inf = 1e18;
const int mod = 1e9 + 7;
typedef pair<int, int> pii;
int n,k,m,c,d;
vector<int> a(N), tag(N), f(N);
//int tag[N], f[N];
int maxn;
bool check(int x){
for(int i = 0; i < N; i++){
tag[i] = 0, f[i] = 0;
}
int res=0;
int lst = c + (m - 1) * d;
for(int i=1;i<=n;i++){
if(a[i]>=x){
res++;
tag[i]=1;
if(res>=k) return true;
}
}
for(int i = 0; i < m; i++){
if(a[i] + c + i * d >= x){
f[m]++;
int xx = (k - c) / d;
int det = i - xx;
f[max(m + det,0ll)]--;
}
}
for(int i = m; i < n; i++){
if(tag[i] == 1) continue;
if(a[i] + lst >= x){
f[i]++;
if(a[i] + c >= x) f[min(i + m, n)]--;
else{
int xx = (k - c) / d;
int det = m - xx;
f[max(i + det, 0ll)]--;
}
}
}
for(int i = m - 1; i < n; i++){
if(res >= k){
return 1;
}
res += f[i];
}
return false;
}
void solve(){
cin>>n>>k>>m>>c>>d;
for(int i=1;i<=n;i++){
cin>>a[i];
}
int ll=0, rr=1e18;
maxn=c+(m-1)*d;
while(ll<rr){
int mid=(ll+rr+1)/2;
if(check(mid))
{
ll=mid;
}
else rr=mid-1;
}
cout<<ll<<endl;
}
signed main(){
KE;
int T = 1;
// cin >> T;
// flt(3);
while(T--){
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 35ms
memory: 26440kb
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: 34ms
memory: 26364kb
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: 34ms
memory: 26460kb
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: 77ms
memory: 26432kb
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: 74ms
memory: 26460kb
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: -100
Wrong Answer
time: 76ms
memory: 26364kb
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:
1000000000
result:
wrong answer 1st numbers differ - expected: '200001000000000', found: '1000000000'