#include<bits/stdc++.h>
using namespace std;
#define int long long
struct obj{
int l,r,a,c,t;
obj(int _l, int _r, int _a, int _c, int pref, int _t){
t = _t - pref;
l = _l;
r = _r;
a = _a;
c = _c;
}
};
signed main(){
int n,m,k,a,b,c,t;
int ans = 0;
cin >> n >> m >> k >> a >> b >> c >> t;
vector<int> arr(m);
for(int i = 0; i < m; i++) cin >> arr[i];
vector<obj> lab;
for(int i = 0,l,r,pre; i <= m-2; i++){
l = arr[i];
r = arr[i+1];
pre = b*(l-1);
if(pre <= t){
lab.push_back(obj(l, r, a, c, pre, t));
}
}
int kkkkk = arr[0];
for(int i = 1; i < m; i++){
kkkkk = b*(arr[i]-1);
if(kkkkk <= t){
ans ++;
}
}
vector<int> stop;
int cnt = 0;
for(auto it = lab.begin(); it != lab.end(); it++){
int i = it->l;
int ran = it->t;
int step = 0,newstep,nextplace;
while(i < it->r){
ran = it->t - c*(i-it->l);
newstep = ran/it->a;
nextplace = min(it->r - 1, i+newstep);
if(i != it->l){
stop.push_back(nextplace - i + 1);
cnt++;
}
else{
ans += (nextplace - i);
}
if(ran < c)break;
if(cnt >= k)break;
i = nextplace+1;
}
}
sort(stop.begin(), stop.end());
reverse(stop.begin(), stop.end());
if((k-m) > stop.size()){
for(auto it = stop.begin(); it != stop.end(); it++){
ans += *it;
}
cout << ans << endl;
}
else{
for(int i = 0; i < (k-m); i++){
ans += stop[i];
}
cout << ans << endl;
}
}
Compilation message
semiexpress.cpp: In function 'int main()':
semiexpress.cpp:41:13: warning: unused variable 'step' [-Wunused-variable]
41 | int step = 0,newstep,nextplace;
| ^~~~
semiexpress.cpp:60:14: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
60 | if((k-m) > stop.size()){
| ~~~~~~^~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |