# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
488650 | 2021-11-19T21:37:46 Z | fun_day | Rice Hub (IOI11_ricehub) | C++14 | 0 ms | 0 KB |
#include <bits/stdc++.h> using namespace std; long long besthub(long long r, long long l, vector<long long> v, long long b){ long long best = 0; for(int i = 0 ; i < r ; i++){ vector<int> sz; long long ans = 0; for(int j = i + 1 ; j < r ; j++){ if(v[j] - v[i] > b) break; sz.emplace_back(v[j] - v[i]); } for(int j = i - 1 ; j >= 0 ; j--){ if(v[i] - v[j] > b) break; sz.emplace_back(v[i] - v[j]); } sort(sz.begin(),sz.end()); long long len = 0; for(int j = 0 ; j < (int)sz.size() ; j++){ len += sz[j]; if(len <= b) ans++; else break; } best = max(best , ans); } return best + 1; } int main(){ ios::sync_with_stdio(false); cin.tie(0); return 0; }