# 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
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 |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
304 KB |
Output is correct |
5 |
Correct |
1 ms |
292 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
304 KB |
Output is correct |
5 |
Correct |
1 ms |
292 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
204 KB |
Output is correct |
13 |
Correct |
1 ms |
304 KB |
Output is correct |
14 |
Correct |
1 ms |
204 KB |
Output is correct |
15 |
Correct |
1 ms |
204 KB |
Output is correct |
16 |
Correct |
3 ms |
204 KB |
Output is correct |
17 |
Correct |
1 ms |
204 KB |
Output is correct |
18 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
304 KB |
Output is correct |
5 |
Correct |
1 ms |
292 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
204 KB |
Output is correct |
13 |
Correct |
1 ms |
304 KB |
Output is correct |
14 |
Correct |
1 ms |
204 KB |
Output is correct |
15 |
Correct |
1 ms |
204 KB |
Output is correct |
16 |
Correct |
3 ms |
204 KB |
Output is correct |
17 |
Correct |
1 ms |
204 KB |
Output is correct |
18 |
Correct |
1 ms |
204 KB |
Output is correct |
19 |
Correct |
2 ms |
332 KB |
Output is correct |
20 |
Correct |
2 ms |
332 KB |
Output is correct |
21 |
Correct |
1 ms |
332 KB |
Output is correct |
22 |
Correct |
2 ms |
332 KB |
Output is correct |
23 |
Correct |
28 ms |
332 KB |
Output is correct |
24 |
Correct |
2 ms |
204 KB |
Output is correct |
25 |
Correct |
1 ms |
204 KB |
Output is correct |
26 |
Correct |
2 ms |
332 KB |
Output is correct |
27 |
Correct |
2 ms |
332 KB |
Output is correct |
28 |
Correct |
2 ms |
336 KB |
Output is correct |
29 |
Correct |
18 ms |
332 KB |
Output is correct |
30 |
Correct |
13 ms |
304 KB |
Output is correct |