제출 #1215913

#제출 시각아이디문제언어결과실행 시간메모리
1215913kunzaZa183쌀 창고 (IOI11_ricehub)C++20
68 / 100
1093 ms992 KiB
#include <bits/stdc++.h>

#include "ricehub.h"
using namespace std;
using ll = long long;

int besthub(int R, int L, int X[], long long B) {
  int maxans = 1;
  for (int i = 0; i < R; i++) {
    vector<ll> vll;
    for (int j = 0; j < R; j++)
      if (j != i) vll.push_back(abs(X[i] - X[j]));

    sort(vll.begin(), vll.end());

    ll cur = 0;
    for (int i = 0; i < vll.size(); i++)
      if (cur + vll[i] > B) {
        maxans = max(maxans, i + 1);
        goto A;
      } else
        cur += vll[i];

    maxans = max(maxans, R);
  A:;
  }
  return maxans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...