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;
using pll = pair<ll, ll>;
using tll = tuple<ll, ll, ll>;
inline void fastio() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
}
const ll INF = 1e16;
ll n, m, k, a, b, c, t, ans;
vector<ll> s, tim, p;
priority_queue<pll> pq;
ll cal(ll x) {
if (tim[x] > t) {
return 0;
} else {
return min((t - tim[x]) / a + 1, s[x + 1] - p[x]);
}
}
int main() {
fastio();
cin >> n >> m >> k >> a >> b >> c >> t;
s.resize(m + 1);
tim.resize(m);
p.resize(m);
for (ll i = 0; i < m; i++) {
cin >> s[i];
s[i]--;
}
s[m] = n, k -= m;
for (ll i = 0; i < m; i++) {
tim[i] = b * s[i];
p[i] = s[i];
}
for (ll i = 0; i < m; i++) {
ll x = max(cal(i), 0LL);
if (x) {
p[i] += x;
tim[i] += x * c;
ans += x;
pq.emplace(cal(i), i);
}
}
while (k-- and !pq.empty()) {
auto [x, idx] = pq.top();
pq.pop();
x = max(x, 0LL);
if (x) {
p[idx] += x;
tim[idx] += x * c;
ans += x;
pq.emplace(cal(idx), idx);
} else {
break;
}
}
cout << ans - 1;
return 0;
}
Compilation message (stderr)
semiexpress.cpp: In function 'int main()':
semiexpress.cpp:62:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
62 | auto [x, idx] = pq.top();
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |