제출 #1066354

#제출 시각아이디문제언어결과실행 시간메모리
1066354DeathIsAwe쌀 창고 (IOI11_ricehub)C++14
17 / 100
16 ms604 KiB
#include "ricehub.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long

int besthub(int r, int l, int x[], long long b) {
  if (r > 5000) {
    return 0;
  }

  int ans = 0, tempans;
  vector<int> dis;
  ll counter;
  for (int i=0;i<r;i++) {
    dis.clear(); counter = 0; tempans = 0;
    for (int j=0;j<r;j++) {
      dis.push_back(abs(x[i] - x[j]));
    }
    dis.push_back(INT32_MAX);
    sort(dis.begin(),dis.end());
    for (int j: dis) {
      if (j == INT32_MAX || counter > b) {
        tempans--;
        break;
      }
      counter += j; tempans++;
    }
    ans = max(ans, tempans);
  }
  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...