#include<bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define in insert
#define er erase
#define pb push_back
#define ppb pop_back()
#define ph push
#define pp pop()
#define d3 ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define cans cout << ans << "\n";
#define yes cout << "YES" << "\n";
#define no cout << "NO" << "\n";
#define pll pair<ll,ll>
#define lin cout << "\n";
#define sqr 340
#define mod 1000000007
#define mid (l+r)/2
using namespace std;
int main()
{
d3
ll n , m , k;
cin >> n >> m >> k;
ll a , b , c;
cin >> a >> b >> c;
ll t;
cin >> t;
ll exp[m];
for(int i = 0 ; m>i ; i++)
cin >> exp[i];
ll ans = 0;
multiset<ll> semi;
ll y = 1e6;
for(int i = 0 ; m-1>i ; i++)
{
if((exp[i]-1)*b>t)
break;
ll l = exp[i]+1;
ll r = exp[i+1]-1;
while(l<=r)
{
if((mid-exp[i])*a+(exp[i]-1)*b>t)
r=mid-1;
else
l=mid+1;
}
ans+=(l-1-exp[i]+1);
ll x = l;
while(x<exp[i+1]&&y)
{
l = x;
r = exp[i+1]-1;
while(l<=r)
{
if((exp[i]-1)*b + (x-exp[i])*c + (mid-x)*a >t)
r=mid-1;
else
l=mid+1;
}
if(l-1==x-1)
break;
y--;
semi.in(l-1-x+1);
x=l;
}
}
ll x = k-m;
while(x--&&!semi.empty())
{
auto it = semi.end();
it--;
//cout << *it << "\n";
ans+=*it;
semi.erase(it);
}
if((n-1)*b<=t)
ans++;
ans--;
cans
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
600 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
600 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
600 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
344 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
212 ms |
47292 KB |
Output is correct |
22 |
Correct |
14 ms |
3928 KB |
Output is correct |
23 |
Correct |
154 ms |
32852 KB |
Output is correct |
24 |
Correct |
230 ms |
47620 KB |
Output is correct |
25 |
Correct |
0 ms |
348 KB |
Output is correct |
26 |
Correct |
1 ms |
348 KB |
Output is correct |
27 |
Correct |
178 ms |
47180 KB |
Output is correct |
28 |
Correct |
199 ms |
47188 KB |
Output is correct |
29 |
Correct |
175 ms |
47216 KB |
Output is correct |
30 |
Correct |
172 ms |
47396 KB |
Output is correct |