QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#726103 | #5417. Chat Program | Moemi_ | WA | 0ms | 3820kb | C++20 | 2.8kb | 2024-11-08 21:38:03 | 2024-11-08 21:38:03 |
Judging History
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) cnt2[1] ++;
if(a[i] + (i - 1) * d + c < t) continue;
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 + (m - pos) <= i - m + 1) cnt2[i + (m - pos)] --;
}
}
}
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] + sum >= t) cnt2[i - m + 1] ++;
if(a[i] + sum < t) continue;
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 + (m - pos) <= i - m + 1) cnt2[i + (m - pos)] --;
}
}
}
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]);
}
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();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3820kb
input:
6 4 3 1 2 1 1 4 5 1 4
output:
6
result:
wrong answer 1st numbers differ - expected: '4', found: '6'