# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
595024 | piOOE | Semiexpress (JOI17_semiexpress) | C++17 | 147 ms | 66148 KiB |
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;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
ll n, m, k;
cin >> n >> m >> k;
ll a, b, c;
cin >> a >> b >> c; //slow, fast, middle
ll t;
cin >> t;
vector<ll> s(m);
for (int i = 0; i < m; ++i) {
cin >> s[i];
}
vector<pair<ll, bool>> v;
ll ans = 0;
s.push_back(n + 1);
for (int i = 0; i <= m; ++i) {
ll dist = (s[i] - 1) * b;
if (dist > t) {
break;
}
ll x = s[i];
int cnt = 0;
while (x < s[i + 1] && dist <= t && cnt < k) {
ll nxt = (t - dist) / a;
if (x + nxt + 1 >= s[i + 1]) {
nxt = s[i + 1] - x - 1;
}
cnt += (x != s[i]);
v.push_back({nxt + 1, x != s[i]});
dist += (nxt + 1) * c;
x += nxt + 1;
}
}
sort(v.begin(), v.end(), greater());
int cnt = m;
for (int i = 0; i < v.size(); ++i) {
if (cnt + v[i].second <= k) {
ans += v[i].first;
cnt += v[i].second;
}
}
cout << ans - 1;
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |