#include <bits/stdc++.h>
#include "ricehub.h"
using namespace std;
#define ll long long
int besthub(int R, int L, int X[], long long B) {
int ans=0;
long long cost=0;
for (int i=1; i<=10000; i++){
multiset<int> se;
for (int j=0; j<R; j++)
se.insert(X[j]);
se.insert(i);
cost=0;
int pans=0;
while(1){
auto ff=se.find(i), rb=se.begin(); rb--;
auto fr=ff, fl=ff; fr++, fl--;
if (fr==se.end() && fl==rb) break;
else if (fr==se.end()){
ll t2=i - *fl;
if (cost + t2 <= B){
cost+=t2;
pans++;
se.erase(fl);
}else break;
}
else if (fl==rb){
ll t1=*fr - i;
if (cost + t1 <= B){
cost+=t1;
pans++;
se.erase(fr);
}else break;
}else{
ll t1=*fr - i,t2=i - *fl;
if (t1<t2){
if (cost + t1 <= B){
cost+=t1;
pans++;
se.erase(fr);
}else break;
}else{
if (cost + t2 <= B){
cost+=t2;
pans++;
se.erase(fl);
}else break;
}
}
}
ans=max(ans, pans);
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
17 ms |
256 KB |
Output is correct |
2 |
Correct |
17 ms |
384 KB |
Output is correct |
3 |
Correct |
27 ms |
256 KB |
Output is correct |
4 |
Correct |
67 ms |
384 KB |
Output is correct |
5 |
Correct |
75 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
14 ms |
384 KB |
Output is correct |
2 |
Correct |
16 ms |
384 KB |
Output is correct |
3 |
Correct |
36 ms |
256 KB |
Output is correct |
4 |
Correct |
32 ms |
384 KB |
Output is correct |
5 |
Correct |
60 ms |
256 KB |
Output is correct |
6 |
Correct |
60 ms |
384 KB |
Output is correct |
7 |
Correct |
93 ms |
384 KB |
Output is correct |
8 |
Correct |
82 ms |
404 KB |
Output is correct |
9 |
Correct |
19 ms |
256 KB |
Output is correct |
10 |
Correct |
16 ms |
256 KB |
Output is correct |
11 |
Correct |
46 ms |
256 KB |
Output is correct |
12 |
Correct |
41 ms |
384 KB |
Output is correct |
13 |
Correct |
39 ms |
256 KB |
Output is correct |
14 |
Correct |
39 ms |
256 KB |
Output is correct |
15 |
Correct |
80 ms |
376 KB |
Output is correct |
16 |
Correct |
84 ms |
384 KB |
Output is correct |
17 |
Correct |
46 ms |
256 KB |
Output is correct |
18 |
Correct |
51 ms |
256 KB |
Output is correct |
19 |
Correct |
80 ms |
256 KB |
Output is correct |
20 |
Correct |
91 ms |
404 KB |
Output is correct |
21 |
Correct |
411 ms |
384 KB |
Output is correct |
22 |
Correct |
431 ms |
384 KB |
Output is correct |
23 |
Correct |
634 ms |
384 KB |
Output is correct |
24 |
Correct |
654 ms |
400 KB |
Output is correct |
25 |
Correct |
654 ms |
404 KB |
Output is correct |
26 |
Correct |
627 ms |
384 KB |
Output is correct |
27 |
Correct |
507 ms |
392 KB |
Output is correct |
28 |
Correct |
512 ms |
396 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
160 ms |
384 KB |
Output is correct |
2 |
Correct |
158 ms |
412 KB |
Output is correct |
3 |
Execution timed out |
1087 ms |
384 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1091 ms |
1408 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |