#include <bits/stdc++.h>
#define loop(i,a,b) for(int i = (a); i < (b); i ++)
#define pb push_back
#define BAE(x) x.begin(), x.end()
#define unisort(x) sort(BAE(x)); x.resize(unique(BAE(x)) - x.begin())
using namespace std;
typedef long long ll;
const int mxn = 3005;
int n, m, k, ans, real_ans;
ll A, B, C, T;
int arr[mxn];
struct range{
ll base, ed, nxt_base, nxt_ed, get, sz;
};
struct cmp{
bool operator()(range x, range y){
return x.get < y.get;
}
};
priority_queue<range, vector<range>, cmp> pq;
inline void build(int l, int r, ll base_cost){
if(l > r) return;
if(base_cost > T) return;
range tmp;
// the cost of the (l-1) th station
tmp.base = base_cost;
tmp.sz = r - l + 1;
// the first station whose distance is greater than T.
tmp.ed = min((T - base_cost) / A + 1, tmp.sz + 1);
ans += tmp.ed - 1;
tmp.nxt_base = tmp.base + tmp.ed * C;
if(tmp.ed > tmp.sz || tmp.nxt_base > T){
return;
}
tmp.nxt_ed = min(tmp.ed + ((T - tmp.nxt_base) / A + 1), tmp.sz + 1);
tmp.get = tmp.nxt_ed - tmp.ed;
if(tmp.get > 0){
pq.push(tmp);
}
}
void solve(){
cin >> n >> m >> k;
cin >> A >> B >> C >> T;
loop(i,0,m){
cin >> arr[i];
}
loop(i,1,m){
if(B * (arr[i] - 1) <= T) ans += 1;
build(arr[i-1] + 1, arr[i] - 1, B * (arr[i-1] - 1));
}
if(pq.empty()){
cout << ans << '\n';
return;
}
loop(build_count,0,k-m){
range now = pq.top();
pq.pop();
ans += now.get;
if(now.nxt_ed != now.sz + 1){
now.base = now.nxt_base;
now.sz -= now.ed;
now.ed = min((T - now.base) / A + 1, now.sz + 1);
if(now.ed <= now.sz && now.base + C <= T){
now.nxt_base = now.base + now.ed * C;
now.nxt_ed = min(now.ed + ((T - now.nxt_base) / A + 1), now.sz + 1);
now.get = now.nxt_ed - now.ed;
if(now.get > 0)
pq.push(now);
}
}
if(pq.empty()) break;
}
cout << ans << '\n';
}
int main(){
ios::sync_with_stdio(false); cin.tie(0);
solve();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 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 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 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 |
344 KB |
Output is correct |
10 |
Correct |
0 ms |
344 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 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 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 |
344 KB |
Output is correct |
10 |
Correct |
0 ms |
344 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 |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
22 |
Correct |
0 ms |
348 KB |
Output is correct |
23 |
Correct |
1 ms |
600 KB |
Output is correct |
24 |
Correct |
1 ms |
604 KB |
Output is correct |
25 |
Correct |
0 ms |
348 KB |
Output is correct |
26 |
Correct |
1 ms |
348 KB |
Output is correct |
27 |
Correct |
1 ms |
604 KB |
Output is correct |
28 |
Correct |
1 ms |
604 KB |
Output is correct |
29 |
Correct |
1 ms |
348 KB |
Output is correct |
30 |
Correct |
0 ms |
344 KB |
Output is correct |