This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 1e6 + 66;
int x[N];
ll d[N];
/*
10 3 5
10 3 5
30
1
6
10
di
0 10 20 30 40 15 25 35 45 27
*/
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
int n, m, k;
cin >> n >> m >> k;
ll A, B, C, T;
cin >> A >> B >> C >> T;
int ans = 0;
for (int i = 1 ; i <= m ; ++ i) {
cin >> x[i];
}
int l = 1;
//cout << "di\n";
for (int i = 1 ; i <= n ; ++ i) {
while (x[l] < i) ++l;
d[i] = ll(1e18);
if (x[l] == i) d[i] = (i - 1) * B;
d[i] = min(d[i], d[i - 1] + A);
//cout << d[i] << " ";
}
//cout << "\n";
vector<int> g;
for (int i = 2 ; i <= m ; ++ i) {
if (d[x[i]] <= T) ans++;
int l = x[i - 1], r = x[i];
int cur = 0;
ll cost = ll(1e18);
for (int j = l + 1 ; j < r ; ++ j) {
if (d[j] <= T) {
ans++;
continue;
}
if (d[j] + (j - l) * (C - A) > T) {
continue;
}
cost += A;
if (cost > T) {
g.push_back(cur);
cost = d[j] + (j - l) * (C - A);
cur = 0;
}
cur++;
}
g.push_back(cur);
}
sort(g.begin(), g.end());
while (g.size() && k > m) {
k--;
ans += g.back();
g.pop_back();
}
cout << ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |