제출 #1327190

#제출 시각아이디문제언어결과실행 시간메모리
1327190vahagngRice Hub (IOI11_ricehub)C++20
42 / 100
1094 ms432 KiB
#include "ricehub.h"
#include <bits/stdc++.h>
using namespace std;

int besthub(int R, int L, int X[], long long B){
  if (R == 1) {
    return 1;
  }
  int ans = 0;
  for (int i = 1; i <= L; i++) {
    priority_queue<long long>pq;
    for (int j = 0; j < R; j++) {
      pq.push({ -abs(X[j] - i) });
    }
    long long cur = B;
    int c = 0;
    while (!pq.empty()){
      auto C = pq.top();
      pq.pop();
      if(cur + C < 0) break;
      cur += C;
      c++;
    }
    ans = max(ans, c);
  }
  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...