#pragma GCC optimize("Ofast")
#pragma GCC target("sse4,avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ts to_string
#define ub upper_bound
#define lb lower_bound
#define ar array
#define all(x) x.begin(), x.end()
#define siz(x) (int)x.size()
#define FOR(x, y, z) for(int x = (y); x < (z); x++)
#define ROF(x, y, z) for(int x = (y-1); x >= (z); x--)
#define F0R(x, z) FOR(x, 0, z)
#define R0F(x, z) ROF(x, z, 0)
#define trav(x, y) for(auto&x:y)
const string nl = "\n";
using ll = int64_t;
using vi = vector<int>;
using vl = vector<ll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using str = string;
using vpii = vector<pii>;
using vpll = vector<pll>;
template<class T> inline bool ckmin(T&a, T b) {return b < a ? a = b, 1 : 0;}
template<class T> inline bool ckmax(T&a, T b) {return b > a ? a = b, 1 : 0;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void usaco(string x=""){
ios_base::sync_with_stdio(0); cin.tie(0); x=x;
#ifndef D
if(siz(x)){
freopen((x+".in").c_str(), "r", stdin);
freopen((x+".out").c_str(), "w", stdout);
}
#endif
}
str ts(char c) { return str(1,c); }
str ts(bool b) { return b ? "true" : "false"; }
str ts(const char* s) { return (str)s; }
str ts(str s) { return s; }
template<class A> str ts(complex<A> c) {
stringstream ss; ss << c; return ss.str(); }
str ts(vector<bool> v) {
str res = "{"; for(int i = 0;i < (int)v.size(); i++) res += char('0'+v[i]);
res += "}"; return res; }
template<size_t SZ> str ts(bitset<SZ> b) {
str res = ""; for(int i = 0; i < b.size(); i++) res += char('0'+b[i]);
return res; }
template<class A, class B> str ts(pair<A,B> p);
template<class T> str ts(T v) {
bool fst = 1; str res = "{";
for (const auto& x: v) {
if (!fst) res += ", ";
fst = 0; res += ts(x);
}
res += "}"; return res;
}
template<class A, class B> str ts(pair<A,B> p) {
return "("+ts(p.f)+", "+ts(p.s)+")"; }
void DBG() { cerr << "]" << endl; }
template<class H, class... T> void DBG(H h, T... t) {
cerr << ts(h); if (sizeof...(t)) cerr << ", ";
DBG(t...); }
#ifdef D
#define dbg(...) cerr << "LINE(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__)
#else
#define dbg(...) 0
#endif
const int mxN = 3001;
int n, m, k, a, b, c, st[mxN], lst; ll t, ans = 0; vl best;
signed main(){
usaco("");
cin >> n >> m >> k >> a >> b >> c >> t;
k-=m;
F0R(i, m){
cin >> st[i];
}
lst = 0;
F0R(i, m-1){
ll tt = (st[i]-1) * b;
if(tt > t) break;
/* dbg(tt); */
ll amt = min((ll)st[i+1]-st[i], (t-tt)/a + 1);
ans += amt;
dbg(ans);
ll pos = amt + st[i];
int used = 0;
while(pos < st[i+1]&&used!=k){
used ++;
ll ti = (pos - st[i]) * c;
dbg(ti, tt);
if(ti + tt > t) break;
amt = min((ll) st[i+1]-pos, ((t-tt-ti)/a + 1));
dbg(amt);
best.pb(amt);
dbg(pos);
pos = amt + pos;
}
}
sort(all(best), greater<int>());
F0R(i, min(k, siz(best))){
ans += best[i];
}
if((n-1)*b<=t) ans++;
cout << ans-1 << nl;
}
/*
* Stuff I should try:
* Is it Monotonic? -> Binary Search
* Is N small? -> Bitsets or other exponential
* Edge Cases? Look Carefully
* Can't figure anything out? Brute Force and see patterns
* Try to prove greedies
* Prefix Sums, Amortization, DP, Data Structures
*/
Compilation message
semiexpress.cpp: In function 'int main()':
semiexpress.cpp:80:18: warning: statement has no effect [-Wunused-value]
80 | #define dbg(...) 0
| ^
semiexpress.cpp:99:9: note: in expansion of macro 'dbg'
99 | dbg(ans);
| ^~~
semiexpress.cpp:80:18: warning: statement has no effect [-Wunused-value]
80 | #define dbg(...) 0
| ^
semiexpress.cpp:105:13: note: in expansion of macro 'dbg'
105 | dbg(ti, tt);
| ^~~
semiexpress.cpp:80:18: warning: statement has no effect [-Wunused-value]
80 | #define dbg(...) 0
| ^
semiexpress.cpp:108:13: note: in expansion of macro 'dbg'
108 | dbg(amt);
| ^~~
semiexpress.cpp:80:18: warning: statement has no effect [-Wunused-value]
80 | #define dbg(...) 0
| ^
semiexpress.cpp:110:13: note: in expansion of macro 'dbg'
110 | dbg(pos);
| ^~~
semiexpress.cpp: In function 'void usaco(std::string)':
semiexpress.cpp:41:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
41 | freopen((x+".in").c_str(), "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
semiexpress.cpp:42:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
42 | freopen((x+".out").c_str(), "w", stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
0 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
0 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
0 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
0 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
0 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
0 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |