이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |