제출 #336075

#제출 시각아이디문제언어결과실행 시간메모리
336075saarang123쌀 창고 (IOI11_ricehub)C++14
0 / 100
25 ms1384 KiB
#include <bits/stdc++.h> #include "ricehub.h" using namespace std; int besthub(int N, int L, int A[], long long B) { int median; if(N % 2) median = A[N / 2]; else median = (A[N / 2 - 1] + A[N / 2]) / 2; vector<int> distance; for(int i = 0; i < N; i++) distance.push_back(abs(A[i] - median)); sort(distance.begin(), distance.end()); int answer = 0; long long cost = 0; for(int i = 0; i < N; i++) if(cost + distance[i] <= B) { cost += distance[i]; answer++; } return answer; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...