#include "ricehub.h"
#include <bits/stdc++.h>
#define ii pair<int,int>
#define fi first
#define se second
#define ll long long
using namespace std;
int besthub(int R, int L, int X[], long long B)
{
int ans=0;
for (int i = 0; i < R; ++i)
{
int idx=i,comp=1;
ll rem=B;
priority_queue<pair<ii,int>,vector<pair<ii,int>>,greater<pair<ii,int> > > q;
if(idx-1>=0)q.push({{X[idx]-X[idx-1],idx-1},0});
if(idx+1<R)q.push({{X[idx+1]-X[idx],idx+1},1});
while(!q.empty()){
pair<ii,int> front =q.top();
q.pop();
if(front.fi.fi>rem)break;
rem-=front.fi.fi,comp++;
if(front.se&&front.fi.se+1<R)
q.push({{X[front.fi.se+1]-X[front.fi.se],front.fi.se+1},1});
if(!front.se&&front.fi.se-1>=0)
q.push({{X[front.fi.se]-X[front.fi.se-1],front.fi.se-1},0});
}
//cerr<<i<<" "<<comp<<"\n";
ans=max(ans,comp);
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
380 KB |
Output is correct |
2 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1004 ms |
612 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |