QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#695577 | #5417. Chat Program | yaLen | WA | 27ms | 26648kb | C++14 | 1.9kb | 2024-10-31 20:19:56 | 2024-10-31 20:20:00 |
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);
int maxn;
bool check(int x){
vector<int>tag(N);
vector<int>f(N);
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 = 1; i <= m; i++){
if(tag[i] == 1) continue;
if(a[i] + c + (i - 1) * d >= x){
f[m]++;
if(a[i] + c >= x){
f[i + m]--;
}else{
//a[i] + c + p * d < x
int p = (x - c - a[i]) / d;
int det = i - p;
f[m + det]--;
}
}
}
for(int i = m + 1; i <= n; i++){
if(tag[i] == 1) continue;
if(a[i] + lst >= x){
f[i]++;
if(a[i] + c >= x) f[i + m]--;
else{
int p = (x - c - a[i]) / d;
int det = m - p;
f[i + det]--;
}
}
}
for(int i = 1; i <= n; i++){
cout << f[i] << " ";
}cout << endl;
for(int i = m; i <= n; i++){
res += f[i];
if(res >= k){
return 1;
}
}
return false;
}
void solve(){
cin >> n >> k >> m >> c >> d;
for(int i = 1; i <= n; i++){
cin >> a[i];
}
int l = 0, r = 1e18;
maxn = c + (m - 1) * d;
while(l < r){
int mid = (l + r + 1) / 2;
// cerr << mid << endl;
if(check(mid))l = mid;
else r = mid - 1;
}
cout << l << 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: 0
Wrong Answer
time: 27ms
memory: 26648kb
input:
6 4 3 1 2 1 1 4 5 1 4
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...
result:
wrong answer 1st numbers differ - expected: '4', found: '0'