#include "ricehub.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
struct field
{
int x,dist;
};
bool byDistance(field a,field b)
{
return a.dist<b.dist;
}
int besthub(int N, int L, int X[], ll B)
{
vector<field> A(N);
for(int i=0;i<N;i++){
A[i].x=X[i];
}
int maximum=0;
for(int k=0;k<N;k++){
for(int i=0;i<N;i++){
A[i].dist=abs(A[i].x-X[k]);
}
sort(A.begin(),A.end(),byDistance);
ll cost=0;
int total=0;
for(int i=0;i<N;i++){
if(cost+(ll)abs(A[i].dist)>B) break;
cost+=(ll)abs(A[i].dist);
total++;
}
maximum=max(maximum,total);
}
return maximum;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
256 KB |
Output is correct |
3 |
Correct |
5 ms |
256 KB |
Output is correct |
4 |
Correct |
5 ms |
376 KB |
Output is correct |
5 |
Correct |
5 ms |
256 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
256 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
5 ms |
256 KB |
Output is correct |
5 |
Correct |
5 ms |
256 KB |
Output is correct |
6 |
Correct |
5 ms |
376 KB |
Output is correct |
7 |
Correct |
5 ms |
256 KB |
Output is correct |
8 |
Correct |
5 ms |
376 KB |
Output is correct |
9 |
Correct |
5 ms |
376 KB |
Output is correct |
10 |
Correct |
5 ms |
256 KB |
Output is correct |
11 |
Correct |
5 ms |
376 KB |
Output is correct |
12 |
Correct |
5 ms |
256 KB |
Output is correct |
13 |
Correct |
5 ms |
256 KB |
Output is correct |
14 |
Correct |
5 ms |
256 KB |
Output is correct |
15 |
Correct |
5 ms |
256 KB |
Output is correct |
16 |
Correct |
5 ms |
376 KB |
Output is correct |
17 |
Correct |
5 ms |
256 KB |
Output is correct |
18 |
Correct |
5 ms |
256 KB |
Output is correct |
19 |
Correct |
5 ms |
256 KB |
Output is correct |
20 |
Correct |
5 ms |
256 KB |
Output is correct |
21 |
Correct |
12 ms |
372 KB |
Output is correct |
22 |
Correct |
10 ms |
376 KB |
Output is correct |
23 |
Correct |
12 ms |
376 KB |
Output is correct |
24 |
Correct |
12 ms |
376 KB |
Output is correct |
25 |
Correct |
13 ms |
256 KB |
Output is correct |
26 |
Correct |
12 ms |
376 KB |
Output is correct |
27 |
Correct |
12 ms |
256 KB |
Output is correct |
28 |
Correct |
12 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
376 KB |
Output is correct |
2 |
Correct |
6 ms |
256 KB |
Output is correct |
3 |
Correct |
30 ms |
376 KB |
Output is correct |
4 |
Correct |
30 ms |
376 KB |
Output is correct |
5 |
Correct |
10 ms |
256 KB |
Output is correct |
6 |
Correct |
10 ms |
376 KB |
Output is correct |
7 |
Correct |
28 ms |
376 KB |
Output is correct |
8 |
Correct |
28 ms |
380 KB |
Output is correct |
9 |
Correct |
12 ms |
376 KB |
Output is correct |
10 |
Correct |
13 ms |
248 KB |
Output is correct |
11 |
Correct |
25 ms |
376 KB |
Output is correct |
12 |
Correct |
25 ms |
376 KB |
Output is correct |
13 |
Correct |
38 ms |
376 KB |
Output is correct |
14 |
Correct |
38 ms |
376 KB |
Output is correct |
15 |
Correct |
12 ms |
376 KB |
Output is correct |
16 |
Correct |
13 ms |
376 KB |
Output is correct |
17 |
Correct |
26 ms |
280 KB |
Output is correct |
18 |
Correct |
26 ms |
376 KB |
Output is correct |
19 |
Correct |
37 ms |
376 KB |
Output is correct |
20 |
Correct |
38 ms |
376 KB |
Output is correct |
21 |
Correct |
698 ms |
504 KB |
Output is correct |
22 |
Correct |
708 ms |
504 KB |
Output is correct |
23 |
Execution timed out |
1093 ms |
376 KB |
Time limit exceeded |
24 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1068 ms |
632 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |