#include<bits/stdc++.h>
using namespace std;
ostream& operator<<(ostream &out, string str) {
for(char c : str) out << c;
return out;
}
template<class L, class R> ostream& operator<<(ostream &out, pair<L, R> p) {
return out << "(" << p.first << ", " << p.second << ")";
}
template<class T> auto operator<<(ostream &out, T a) -> decltype(a.begin(), out) {
out << "{";
for(auto it = a.begin(); it != a.end(); it = next(it))
out << (it != a.begin() ? ", " : "") << *it;
return out << "}";
}
void dump() { cerr << "\n"; }
template<class T, class... Ts> void dump(T a, Ts... x) {
cerr << a << ", ";
dump(x...);
}
#ifdef DEBUG
# define debug(...) cerr << "[" #__VA_ARGS__ "]: ", dump(__VA_ARGS__)
#else
# define debug(...) false
#endif
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define ST first
#define ND second
template<class T> int size(T && a) { return a.size(); }
using LL = long long;
using PII = pair<int, int>;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n, m, k;
LL a, b, c, t;
cin >> n >> m >> k >> a >> b >> c >> t;
vector<LL> s(m);
k -= m;
REP(i, m) cin >> s[i];
s.emplace_back(n + 1);
LL f = min(a, min(b, c));
debug(f);
LL ans = -1;
vector<LL> best;
REP(i, m) {
LL time_elapsed = f * (s[i] - 1);
debug(i, s[i], time_elapsed);
if(time_elapsed > t) break;
LL pos = s[i] + (t - time_elapsed) / a;
pos = min(pos, s[i + 1] - 1);
ans += pos - s[i] + 1;
debug(i, s[i], pos, ans);
REP(j, k) {
LL last = pos;
pos++;
if(pos >= s[i + 1]) break;
time_elapsed = f * (s[i] - 1) + (pos - s[i]) * c;
debug(pos, time_elapsed);
if(time_elapsed > t) break;
pos += (t - time_elapsed) / a;
pos = min(pos, s[i + 1] - 1);
debug(pos, last);
best.emplace_back(pos - last);
}
}
debug(best);
sort(best.rbegin(), best.rend());
REP(i, min(k, size(best)))
ans += best[i];
cout << ans << "\n";
}
Compilation message
semiexpress.cpp: In function 'int main()':
semiexpress.cpp:55:10: warning: statement has no effect [-Wunused-value]
debug(f);
^
semiexpress.cpp:60:31: warning: statement has no effect [-Wunused-value]
debug(i, s[i], time_elapsed);
^
semiexpress.cpp:65:27: warning: statement has no effect [-Wunused-value]
debug(i, s[i], pos, ans);
^
semiexpress.cpp:71:28: warning: statement has no effect [-Wunused-value]
debug(pos, time_elapsed);
^
semiexpress.cpp:75:20: warning: statement has no effect [-Wunused-value]
debug(pos, last);
^
semiexpress.cpp:80:13: warning: statement has no effect [-Wunused-value]
debug(best);
^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
3 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
3 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
504 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
2 ms |
376 KB |
Output is correct |
13 |
Correct |
3 ms |
544 KB |
Output is correct |
14 |
Correct |
2 ms |
376 KB |
Output is correct |
15 |
Correct |
2 ms |
376 KB |
Output is correct |
16 |
Correct |
2 ms |
376 KB |
Output is correct |
17 |
Correct |
3 ms |
348 KB |
Output is correct |
18 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
3 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
504 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
2 ms |
376 KB |
Output is correct |
13 |
Correct |
3 ms |
544 KB |
Output is correct |
14 |
Correct |
2 ms |
376 KB |
Output is correct |
15 |
Correct |
2 ms |
376 KB |
Output is correct |
16 |
Correct |
2 ms |
376 KB |
Output is correct |
17 |
Correct |
3 ms |
348 KB |
Output is correct |
18 |
Correct |
2 ms |
376 KB |
Output is correct |
19 |
Correct |
2 ms |
504 KB |
Output is correct |
20 |
Correct |
2 ms |
376 KB |
Output is correct |
21 |
Correct |
2 ms |
380 KB |
Output is correct |
22 |
Correct |
4 ms |
656 KB |
Output is correct |
23 |
Correct |
25 ms |
4592 KB |
Output is correct |
24 |
Correct |
2 ms |
504 KB |
Output is correct |
25 |
Correct |
2 ms |
376 KB |
Output is correct |
26 |
Correct |
2 ms |
376 KB |
Output is correct |
27 |
Correct |
2 ms |
504 KB |
Output is correct |
28 |
Correct |
2 ms |
376 KB |
Output is correct |
29 |
Correct |
20 ms |
4556 KB |
Output is correct |
30 |
Correct |
13 ms |
2516 KB |
Output is correct |