#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;
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;
if(tmp.ed > tmp.sz || tmp.base + C > T){
return;
}
tmp.nxt_base = tmp.base + tmp.ed * C;
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);
}
int main(){
ios::sync_with_stdio(false); cin.tie(0);
// freopen("in.txt", "r", stdin);
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 0;
}
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';
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |