제출 #1249348

#제출 시각아이디문제언어결과실행 시간메모리
1249348_HDH쌀 창고 (IOI11_ricehub)C++20
42 / 100
1095 ms428 KiB
#include "ricehub.h"
#include <bits/stdc++.h>

using namespace std;

int besthub(int R, int L, int X[], long long B)
{
    int ans = 0;
    for (int j = 1; j <= L; j++){
        vector<int> vt;
        for (int i = 0; i < R; i++){
            
            vt.push_back(abs(X[i] - j));
        }
        
        
        sort(vt.begin(), vt.end());
        int sum = 0;
        int k = 0;
        while (k < vt.size() && sum + vt[k] <= B)
            sum += vt[k++];
        
        ans = max(ans, k);

    }
  return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...