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>
#define ll long long
#define ull unsigned ll
#define pb push_back
#define pa pair<int, int>
#define pall pair<ll, int>
#define fi first
#define se second
#define TASK "test"
#define Size(x) (int) x.size()
#define all(x) x.begin(), x.end()
using namespace std;
template<typename T1, typename T2> bool mini (T1 &a, T2 b) {if(a > b) a = b; else return 0; return 1;}
template<typename T1, typename T2> bool maxi (T1 &a, T2 b) {if(a < b) a = b; else return 0; return 1;}
const int MOD = 1e9 + 7;
const int LOG = 20;
const int maxn = 2e5 + 7;
const ll oo = 1e18 + 69;
int n, m, k, a, b, c, s[maxn];
ll t;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
//freopen(TASK".inp", "r", stdin);
//freopen(TASK".out", "w", stdout);
cin>>n>>m>>k>>a>>b>>c>>t;
for(int i = 1; i <= m; i++) cin>>s[i];
k -= m;
int ans = 0;
vector<int> val;
for(int i = 1; i <= m; i++) {
ll time = 1LL * (s[i] - 1) * b;
if(time <= t && i != 1) ans++;
if(time > t || i == m) break;
ll cnt = 0;
cnt += (t - time) / a;
ll last = s[i] + cnt + 1;
while(k > 0 && last < s[i + 1]) {
time = 1LL * (s[i] - 1) * b + 1LL * c * (last - s[i]);
if(time > t) break;
last = last + (t - time) / a + 1;
if(last > s[i + 1]) {
last -= (t - time) / a + 1;
val.pb(min(s[i + 1] - last, (t - time) / a + 1));
break;
}
cnt += (t - time) / a + 1;
k--;
}
mini(cnt, s[i + 1] - s[i] - 1);
ans += cnt;
}
sort(all(val), greater<int> ());
for(int i = 0; i < min(k, Size(val)); i++) ans += val[i];
cout<<ans;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |