// #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,popcnt,abm,mmx,avx")
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <unordered_map>
#include <set>
#include <map>
#include <queue>
#include <random>
#include <chrono>
#define fi first
#define se second
#define pb push_back
#define ll long long
#define ld long double
#define hm unordered_map
#define pii pair<int, int>
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define cinv(v) for (auto& x: v) cin >> x
#define fr(i, n) for (int i = 0; i < n; ++i)
#define fl(i, l, n) for (int i = l; i < n; ++i)
#define int ll
template <typename T1, typename T2> inline bool chkmin(T1 &x, const T2 &y) {if (x > y) {x = y; return 1;} return 0;}
template <typename T1, typename T2> inline bool chkmax(T1 &x, const T2 &y) {if (x < y) {x = y; return 1;} return 0;}
using namespace std;
#ifdef LOCAL
#define dbg(x) cerr << #x << " : " << x << '\n'
#else
#define dbg(x)
#endif
//tg: @runningcherry
template <typename T1, typename T2> ostream& operator << (ostream& out, const pair<T1, T2>& v) {
out << v.fi << ", " << v.se;
return out;
}
template<typename T> ostream& operator << (ostream& out, const vector<T>& v) {
for (auto& x: v) out << x << " ";
return out;
}
template <typename T1, typename T2> istream& operator >> (istream& in, pair<T1, T2>& a) {
in >> a.fi >> a.se;
return in;
}
const ll inf = (ll) 2e9;
const ld pi = asin (1) * 2;
const ld eps = 1e-8;
const ll mod = (ll)1e9 + 7;
const ll ns = 97;
const int maxn = 2e5 + 20;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
struct gay {
int i, t, x;
inline bool operator < (const gay& other) const {
return x > other.x;
}
};
signed main () {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int n, m, k, a, b, c, t;
cin >> n >> m >> k >> a >> b >> c >> t;
vector<int> goo (m);
cinv (goo);
multiset <gay> kek;
for (auto& x: goo) --x;
int res = b * goo.back () <= t;
fr (i, m - 1) {
int l = goo[i], r = min (goo[i + 1] - 1, goo[i] + (t - b * goo[i]) / a);
if (b * goo[i] <= t) {
dbg (l);
dbg (r);
dbg (goo[i]);
dbg (r - l + 1);
res += r - l + 1;
}
if (r + 1 != goo[i + 1] && (t - b * goo[i] - (r + 1 - goo[i]) * c) >= 0)
kek.insert ({r + 1, b * goo[i] + (r + 1 - goo[i]) * c, min (goo[i + 1] - 1, r + 1 + (t - b * goo[i] - (r + 1 - goo[i]) * c) / a) - r});
}
fr (i, k - m) {
if (kek.empty ()) break;
auto ptt = *kek.begin ();
kek.erase (kek.begin ());
dbg (ptt.i);
res += ptt.x;
int r = ptt.i + ptt.x;
auto it = lower_bound (all (goo), r) - goo.begin ();
if (ptt.t + (r - ptt.i) * c <= t && r < goo[it])
kek.insert ({r, ptt.t + (r - ptt.i) * c, min (goo[it] - 1, r + (t - ptt.t - (r - ptt.i) * c) / a) - r + 1});
}
cout << res - 1 << '\n';
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
0 ms |
364 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
11 |
Correct |
1 ms |
364 KB |
Output is correct |
12 |
Correct |
1 ms |
364 KB |
Output is correct |
13 |
Correct |
0 ms |
364 KB |
Output is correct |
14 |
Correct |
1 ms |
364 KB |
Output is correct |
15 |
Correct |
1 ms |
364 KB |
Output is correct |
16 |
Correct |
1 ms |
364 KB |
Output is correct |
17 |
Correct |
1 ms |
364 KB |
Output is correct |
18 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
0 ms |
364 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
11 |
Correct |
1 ms |
364 KB |
Output is correct |
12 |
Correct |
1 ms |
364 KB |
Output is correct |
13 |
Correct |
0 ms |
364 KB |
Output is correct |
14 |
Correct |
1 ms |
364 KB |
Output is correct |
15 |
Correct |
1 ms |
364 KB |
Output is correct |
16 |
Correct |
1 ms |
364 KB |
Output is correct |
17 |
Correct |
1 ms |
364 KB |
Output is correct |
18 |
Correct |
1 ms |
364 KB |
Output is correct |
19 |
Correct |
1 ms |
364 KB |
Output is correct |
20 |
Correct |
1 ms |
364 KB |
Output is correct |
21 |
Correct |
1 ms |
364 KB |
Output is correct |
22 |
Correct |
1 ms |
364 KB |
Output is correct |
23 |
Correct |
1 ms |
492 KB |
Output is correct |
24 |
Correct |
1 ms |
492 KB |
Output is correct |
25 |
Correct |
1 ms |
364 KB |
Output is correct |
26 |
Correct |
1 ms |
364 KB |
Output is correct |
27 |
Correct |
1 ms |
492 KB |
Output is correct |
28 |
Correct |
1 ms |
492 KB |
Output is correct |
29 |
Correct |
1 ms |
364 KB |
Output is correct |
30 |
Correct |
1 ms |
364 KB |
Output is correct |