QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#692081#5417. Chat Program42m0rr0w#Compile Error//C++201.2kb2024-10-31 13:46:502024-10-31 13:46:50

Judging History

你现在查看的是最新测评结果

  • [2024-10-31 13:46:50]
  • 评测
  • [2024-10-31 13:46:50]
  • 提交

answer

#include <bits/stdc++.h>
#define test(x) cout << #x <<" = " << x << endl
#define int long long
#define vint vector<int>
#define endl "\n"
using namespace std;
const int N = 2e5 + 5;

int a[N];
int n, k, m, c, d;

int Cal(int x) {
    vint b(n + 2);
    for (int i = 1; i <= n; ++i) {
        if (a[i] >= x)
            b[1]++;
        else if (a[i] + min(i-1, m-1) * d + c >= x) {
            b[max(1ll, i - m + 1)]++;
            if (!d) {
                b[i+1]--;
            }
            else {
                int tt = (x - a[i] - c + d - 1) / d;
                b[i-tt+1]--;
            }
        }
    }
    int ans = 0, t = 0;
    for (int i = 1; i <= n -m + 1; ++i) {
        t += b[i];
        ans = max(ans, t);
    }
    return ans;
}

void sol(){
    cin >> n >> k >> m >> c >> d;
    // vint a(n + 1);
    for (int i = 1; i <= n; ++i)
        cin >> a[i];
    int l = 0, r = 1e18, mid;
    while (l < r) {
        int mid = (l + r + 1) >> 1;
        if (Cal(mid) >= k) l = mid;
        else r = mid - 1;
    }
    cout << l << endl;
}

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int T = 1;
    // cin >> T;
    while(T--) {
        sol();
    }
    return 0;
}
/*

*

详细

answer.code:60:1: error: unterminated comment
   60 | /*
      | ^