| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 897510 | ThylOne | 쌀 창고 (IOI11_ricehub) | C++14 | 1086 ms | 348 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "ricehub.h"
#include<bits/stdc++.h>
using namespace std;
vector<int> pos;
long long budget;
int limit;
bool existWithT(int T){
int sum = 0;
for(int i=0;i<T;i++)
sum+=pos[i];
auto computeScore = [&](int x,int l,int r){
int re = 0;
for(int i = l;i<=r;i++){
re+=abs(x-pos[i]);
}
return re;
};
auto findGoodSegment = [&](int l,int r){
int bestInf = double(sum)/double(T);
int bestSup = ceil(double(sum)/double(T));
if(computeScore(bestInf,l,r)<=budget)return true;
if(computeScore(bestSup,l,r)<=budget)return true;
return false;
};
if(findGoodSegment(0,T-1))return true;
for(int right=T;right<pos.size();right++){
sum-=pos[right-T];
sum+=pos[right];
if(findGoodSegment(right-T+1,right))return true;
}
return false;
}
int besthub(int R, int L, int X[], long long B)
{
budget = B;
pos.resize(R);
limit = L;
for(int i = 0;i<R;i++){
pos[i] = X[i];
}
sort(pos.begin(),pos.end());
int low = 1;
int high = R;
while (low<high){
int mid = (low+high)/2;
if(existWithT(mid)){
low = mid;
}else{
high = mid-1;
}
}
return low;
}
컴파일 시 표준 에러 (stderr) 메시지
| # | 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... | ||||
