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 f first
#define s second
#define pb push_back
using namespace std;
const int N=3e5+5;
long long n,m,k,t,a,b,c,a1[N],ans,mx,cur,pre,st,x;
vector <int> v;
multiset <long long> ms;
multiset <long long> ::iterator it;
int main() {
cin>>n>>m>>k;
cin>>a>>b>>c;
cin>>t;
for (int i=1; i<=m;i++){
cin>>a1[i];
}
for (int i=1; i<m; i++) {
cur=(a1[i]-1)*b;
if (cur>t) continue;
mx=a1[i]+(t-cur)/a;
//cout<<i<<" "<<cur<<" "<<mx<<endl;
if (mx>=a1[i+1]-1) {
ans+=a1[i+1]-a1[i];
// cout<<a1[i]<<" "<<a1[i+1]-1<<endl;
continue;
}
ans+=mx-a1[i]+1;
// cout<<a1[i]<<" "<<mx<<endl;
pre=a1[i];
st=mx+1;
int ww=0;
while (true) {
ww++;
if (ww>k-m) break;
cur+=(st-pre)*c;
// cout<<st<<" "<<pre<<" "<<cur<<endl;
if (cur>t) break;
mx=st+(t-cur)/a;
mx=min(mx,a1[i+1]-1);
//cout<<mx<<endl<<endl;
// cout<<st<<" "<<mx<<endl;
ms.insert(mx-st+1);
if (ms.size()>k-m) {
it=ms.begin();
x=*it;
ms.erase(ms.find(x));
}
pre=st;
st=mx+1;
if (mx==a1[i+1]-1) break;
}
}
if ((a1[m]-1)*b<=t) ans++;
for (it=ms.begin(); it!=ms.end(); it++) {
x=*it;
ans+=x;
}
cout<<ans-1<<endl;
}
Compilation message (stderr)
semiexpress.cpp: In function 'int main()':
semiexpress.cpp:45:28: warning: comparison of integer expressions of different signedness: 'std::multiset<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
45 | if (ms.size()>k-m) {
| ~~~~~~~~~^~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |