#include <bits/stdc++.h>
#include "ricehub.h"
using namespace std;
#define endl "\n"
#define x first
#define y second
#define pii pair<int,int>
typedef long long int ll;
vector<int> v;
int besthub(int R, int L, int X[], long long B)
{
int n=R;
ll w=B;
v.resize(n+1);
for(int i=0; i<n; i++) {
v[i+1]=X[i];
}
int idx=n/2 ;
vector<pii> l,r;
int cur=0;
int curv=0;
for(int i=idx+1; i<=n; i++) {
curv+=v[i]-v[idx];
cur++;
r.push_back({curv,cur});
}
r.push_back({0,0});
l.push_back({0,0});
cur=0;
curv=0;
for(int i=idx-1; i>=0; i--) {
curv+=abs(v[i]-v[idx]);
cur++;
l.push_back({curv,cur});
}
int ans=0;
for(pii u:l) {
for(pii v:r) {
if(u.x+v.x<=w) {
ans=max(ans,u.y+v.y);
}
}
}
ans++;
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
256 KB |
Output is correct |
2 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
82 ms |
952 KB |
Output is correct |
2 |
Correct |
86 ms |
956 KB |
Output is correct |
3 |
Execution timed out |
1067 ms |
3292 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |