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;
#define fi first
#define se second
#define lo long long
#define inf 1000000000
#define md 1000000007
#define li 300005
#define mp make_pair
#define pb push_back
#define pi pair<lo int, int>
#define endl "\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0);
#define fi first
#define se second
#define pii pair<ll,ll>
#define pq priority_queue
#define UwU uwu
#define UwU Mikuwu
#define Miku best_waifu
#define Miku_dancing god_waving
#define Miku_singing god_shaking
#define a_Miku cho_doi_bot_ngu
int n, m, k, s[30005], mx;
long long a, b, c, t, rem[30005], ans;
pq< pair<int, int> > q;
long long int calc(int ind){
long long tut = (t - (s[ind] - 1) * b - (s[ind + 1] - s[ind] - 1 - rem[ind]) * c);
if(tut < c) return 0;
return min(rem[ind], (tut - c) / a + 1);
}
int main(){
cin >> n >> m >> k >> a >> b >> c >> t;
for(int i = 1; i <= m ; i ++){
cin >> s[i];
}
for(int i = 1; i < m ; i ++){
if((s[i] - s[1]) * b > t) break;
mx = i;
}
for(int i = 1; i <= mx ; i ++){
rem[i] = max(0ll, (s[i + 1] - s[i] - 1) - (t - (s[i] - 1) * b) / a);
q.push(mp(calc(i), i));
}
k -= m;
while(k --){
int temp = q.top().fi;
int ind = q.top().se;
q.pop();
rem[ind] -= temp;
q.push(mp(calc(ind), ind));
}
for(int i = 1; i <= mx; i ++){
ans += s[i + 1] - s[i] - rem[i];
}
if((s[m] - 1) * b <= t) ans ++;
cout << ans - 1;
return 0;
}
Compilation message (stderr)
semiexpress.cpp:21:0: warning: "UwU" redefined
#define UwU Mikuwu
semiexpress.cpp:20:0: note: this is the location of the previous definition
#define UwU uwu
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |