-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAOJ0637.cpp
82 lines (65 loc) · 1.79 KB
/
AOJ0637.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pii;
typedef pair<ll, ll> pll;
#define FOR(i, s, e) for (ll(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (ll(i) = (s); (i) > (e); (i)--)
#define debug(x) cout << #x << ": " << x << endl
#define mp make_pair
#define pb push_back
const ll MOD = 1000000007;
const ll INF = 1e9;
const ll LINF = 1e16;
const double PI = acos(-1.0);
ll dx[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };
ll dy[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };
/* ----- 2017/04/19 Problem: / Link: ----- */
/* ------問題------
-----問題ここまで----- */
/* -----解説等-----
到達駅について考えると、急行の停車駅が遠いときは到達可能な点から一個遠い点を、
準急の駅にすればよい。ただしそうできるのはK-M個の駅だけなので、
感覚が最大になるような駅をとりたくなる。すべて列挙し大きいものだけを見ればよい。
ans-1はs[M]を作った分。実装が楽になるので
----解説ここまで---- */
ll N, M, K, A, B, C, T;
ll ans = 0LL;
int main() {
cin.tie(0);
ios_base::sync_with_stdio(false);
cin >> N >> M >> K >> A >> B >> C >> T;
ll s[3010];
FOR(i, 0, M) {
cin >> s[i];
}
s[M] = N + 1;
vector<ll> v;
FOR(i, 0, M) {
ll c = (s[i] - 1)*B;
ll cv = max(0LL, (T - c) / A + 1);
ll ss = s[i];
ll pos = s[i] + cv;
if (c > T)break;
if (pos > s[i + 1])pos = s[i + 1];
ans += pos - ss;
FOR(j, 0, K - M) {
if (pos >= s[i + 1])break;
c += (pos - ss)*C;
if (c > T)break;
cv = max(0LL, (T - c) / A + 1);
ss = pos;
pos += cv;
if (pos > s[i + 1])pos = s[i + 1];
v.pb(pos - ss);
}
}
sort(v.rbegin(), v.rend());
FOR(i, 0, K - M) {
if (i < (ll)v.size()) {
ans += v[i];
}
}
cout << ans - 1 << endl;
return 0;
}