Submission #1015739

#TimeUsernameProblemLanguageResultExecution timeMemory
1015739KasymKRice Hub (IOI11_ricehub)C++17
17 / 100
1051 ms936 KiB
#include "bits/stdc++.h" using namespace std; #define pb push_back #define ll long long #define ff first #define ss second #define all(v) v.begin(), v.end() int besthub(int r, int l, int x[], ll b){ int ans = 0; for(int hub = 1; hub <= l; ++hub){ vector<int> v; for(int i = 0; i < r; ++i) v.pb(abs(hub-x[i])); sort(v.rbegin(), v.rend()); ll b_ = b; int cnt = 0; while(1){ int x = v.back(); if(b_-x >= 0) b_ -= x, v.pop_back(), cnt++; else break; } ans = max(ans, cnt); } return ans; } // const int N = 20; // int a[N]; // int main(){ // int r, l; // ll b; // r = 5, l = 20, b = 6; // a[0] = 1, a[1] = 2, a[2] = 10, a[3] = 12, a[4] = 14; // printf("%d\n", besthub(r, l, a, b)); // return 0; // }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...