QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#667530 | #5417. Chat Program | 1ockhart | WA | 1ms | 3832kb | C++20 | 1.5kb | 2024-10-22 23:57:14 | 2024-10-22 23:57:20 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("avx2")
using ll = long long;
//using i128 = __int128_t;
#define endl "\n"
#define int long long
#define db cout << "db" << endl;
#define x first
#define y second
typedef pair<int, int> PII;
const int N = 5e5 + 10;
ll inf = 2e18;
void solve() {
int n, k, m, c, d;
cin >> n >> k >> m >> c >> d;
vector<int> a(n + 1);
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
int l = 0, r = 1e9 + 10;
while (l <= r) {
int mid = (l + r) >> 1, cnt = 0;
vector<int> s(n + 1, 0);
for (int i = 1; i <= n; i++) {
cnt += (a[i] >= mid);
}
for (int i = 1; i <= n; i++) {
if (a[i] >= mid) {
continue;
}
int x;
if (!d) {
x = 0;
x = (a[i] + c >= mid ? 0 : 1e15);
} else {
x = (mid - a[i] - c) / d;
}
int p1 = max(i - x + 1, 0LL), p2 = max(i - m + 1, 0LL);
p1 = max(p1, p2);
s[p1]--;
s[p2]++;
}
int mx = 0, res = 0;
for (int i = 1; i <= n; i++) {
res += s[i];
mx = max(mx, res);
}
if (mx + cnt >= k) {
l = mid + 1;
} else {
r = mid - 1;
}
}
cout << r << endl;
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
int q = 1;
//cin >> q;
while (q --) {
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3832kb
input:
6 4 3 1 2 1 1 4 5 1 4
output:
1
result:
wrong answer 1st numbers differ - expected: '4', found: '1'