Submission #302440

#TimeUsernameProblemLanguageResultExecution timeMemory
302440nhdtxdyRice Hub (IOI11_ricehub)C++17
42 / 100
1069 ms788 KiB
#include <bits/stdc++.h> #define ll long long using namespace std; const int nax = 1e5 + 5; int n, maxi, a[nax]; ll b; // Subtask 3 int solve() { int ans = 0; for (int i = 1; i <= n; ++i) { // select a[i] as the position priority_queue<int, vector<int>, greater<int>> pq; for (int j = 1; j <= n; ++j) { pq.push(abs(a[i] - a[j])); } int cnt = 0, curr = 0; while (!pq.empty() && curr <= b) { ++cnt; curr += pq.top(); pq.pop(); } if (curr > b) --cnt; ans = max(ans, cnt); } return ans; } int besthub(int R, int L, int X[], long long B) { n = R; maxi = L; for (int i = 0; i < R; ++i) a[i + 1] = X[i]; b = B; return solve(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...