#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<int,int>
#define p_q priority_queue
#define pb push_back
signed main() {
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int N, M, K; cin>>N>>M>>K;
K -= M;
int L, Ex, Sm; cin>>L>>Ex>>Sm;
int T; cin>>T;
vector<int> S(M+2);
p_q < pair<int,pii> > pq;
for (int i = 1; i <= M; ++i) cin>>S[i];
int ans = 0;
for (int i = 1; i <= M-1; ++i) {
int curT = T-Ex*(S[i]-1), tmp = S[i];
if (curT < 0) continue;
int l = 0, r = S[i+1]-tmp;
while(r-l > 1) {
int mid = (l+r)>>1;
if (curT-mid*L >= 0) l = mid;
else r = mid;
}
ans += l+1;
//cout<<S[i]<<' '<<S[i]+l<<endl;
tmp = S[i]+l+1;
curT -= (l+1)*Sm;
if (curT < 0 || tmp == S[i+1]) continue;
l = 0, r = S[i+1]-tmp;
while(r-l > 1) {
int mid = (l+r)>>1;
if (curT-mid*L >= 0) l = mid;
else r = mid;
}
pq.push({l+1,{i,tmp+l+1}});
}
while(K && !pq.empty()) {
//cout<<"pass"<<endl;
pair<int,pii> cur = pq.top();
pq.pop();
ans += cur.first;
K--;
int tmp = cur.second.second;
int curT = T-Ex*(S[cur.second.first]-1)-Sm*(tmp-S[cur.second.first]);
if (curT < 0 || tmp == S[cur.second.first+1]) continue;
int l = 0, r = S[cur.second.first+1]-tmp;
while(r-l > 1) {
int mid = (l+r)>>1;
if (curT-mid*L >= 0) l = mid;
else r = mid;
}
pq.push({l+1,{cur.second.first,tmp+l+1}});
}
if ((N-1)*Ex <= T) ans++;
cout<<ans-1<<'\n';
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
604 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
604 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
600 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
22 |
Correct |
1 ms |
348 KB |
Output is correct |
23 |
Correct |
1 ms |
348 KB |
Output is correct |
24 |
Correct |
1 ms |
348 KB |
Output is correct |
25 |
Correct |
0 ms |
348 KB |
Output is correct |
26 |
Correct |
1 ms |
468 KB |
Output is correct |
27 |
Correct |
1 ms |
360 KB |
Output is correct |
28 |
Correct |
1 ms |
348 KB |
Output is correct |
29 |
Correct |
0 ms |
348 KB |
Output is correct |
30 |
Correct |
0 ms |
348 KB |
Output is correct |