#include "ricehub.h"
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long
#define pll pair<ll, ll>
/*ll p[5005];
pll binary1(ll b, ll e, ll num, ll money)
{
ll l = b, r = e, ans = 0;
while (l <= r){
ll m = (l + r)/2;
if (p[m] - p[b-1] - ((m-b+1)*num) <= money){
l = m + 1;
ans = money - (p[m] - p[b-1] - ((m-b+1)*num));
}
else {
r = m - 1;
}
}
return {ans, l-1};
}
pll binary2(ll b, ll e, ll num, ll money)
{
ll l = b, r = e, ans = 0;
while (l <= r){
ll m = (l + r)/2;
if ((e-m+1)*num - (p[e] - p[m-1]) <= money){
r = m - 1;
ans = money - (e-m+1)*num - (p[e] - p[m-1]);
}
else {
l = m + 1;
}
}
return {ans, r+1};
}*/
int besthub(int n, int l, int a[], long long b)
{
/*for (ll i = 0; i<n; i++){
p[i+1] = p[i] + a[i];
}*/
ll mx = 0;
for (ll i = 0; i<n; i++){
priority_queue<ll, vector<ll>, greater<ll>>pq;
for (ll j = 0; j<i; j++){
pq.push(a[i] - a[j]);
}
for (ll j = i; j<n; j++){
pq.push(a[j] - a[i]);
}
ll sum = 0, cnt = 0;
while (pq.size()){
ll x = pq.top();
pq.pop();
sum += x;
cnt++;
if (sum > b){
sum -= x;
cnt--;
break;
}
}
mx = max(mx, cnt);
}
return mx;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
600 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 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 |
1 ms |
344 KB |
Output is correct |
15 |
Correct |
1 ms |
596 KB |
Output is correct |
16 |
Correct |
1 ms |
344 KB |
Output is correct |
17 |
Correct |
0 ms |
448 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
448 KB |
Output is correct |
21 |
Correct |
2 ms |
348 KB |
Output is correct |
22 |
Correct |
2 ms |
348 KB |
Output is correct |
23 |
Correct |
7 ms |
348 KB |
Output is correct |
24 |
Correct |
8 ms |
444 KB |
Output is correct |
25 |
Correct |
7 ms |
348 KB |
Output is correct |
26 |
Correct |
9 ms |
348 KB |
Output is correct |
27 |
Correct |
6 ms |
456 KB |
Output is correct |
28 |
Correct |
5 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
30 ms |
348 KB |
Output is correct |
4 |
Correct |
29 ms |
604 KB |
Output is correct |
5 |
Correct |
2 ms |
344 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
6 ms |
600 KB |
Output is correct |
8 |
Correct |
6 ms |
348 KB |
Output is correct |
9 |
Correct |
3 ms |
456 KB |
Output is correct |
10 |
Correct |
3 ms |
448 KB |
Output is correct |
11 |
Correct |
8 ms |
344 KB |
Output is correct |
12 |
Correct |
7 ms |
476 KB |
Output is correct |
13 |
Correct |
41 ms |
348 KB |
Output is correct |
14 |
Correct |
39 ms |
348 KB |
Output is correct |
15 |
Correct |
4 ms |
344 KB |
Output is correct |
16 |
Correct |
4 ms |
348 KB |
Output is correct |
17 |
Correct |
22 ms |
348 KB |
Output is correct |
18 |
Correct |
24 ms |
348 KB |
Output is correct |
19 |
Correct |
38 ms |
348 KB |
Output is correct |
20 |
Correct |
36 ms |
344 KB |
Output is correct |
21 |
Correct |
237 ms |
348 KB |
Output is correct |
22 |
Correct |
219 ms |
460 KB |
Output is correct |
23 |
Execution timed out |
1049 ms |
600 KB |
Time limit exceeded |
24 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1052 ms |
1084 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |