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