Submission #1003347

#TimeUsernameProblemLanguageResultExecution timeMemory
1003347vjudge1Rice Hub (IOI11_ricehub)C++17
68 / 100
1047 ms1220 KiB
#include "ricehub.h" #include <bits/stdc++.h> using namespace std; #define endl '\n' #define ll long long #define pll pair<ll, ll> /*ll p[5005]; pll binary1(ll b, ll e, ll num, ll money) { ll l = b, r = e, ans = 0; while (l <= r){ ll m = (l + r)/2; if (p[m] - p[b-1] - ((m-b+1)*num) <= money){ l = m + 1; ans = money - (p[m] - p[b-1] - ((m-b+1)*num)); } else { r = m - 1; } } return {ans, l-1}; } pll binary2(ll b, ll e, ll num, ll money) { ll l = b, r = e, ans = 0; while (l <= r){ ll m = (l + r)/2; if ((e-m+1)*num - (p[e] - p[m-1]) <= money){ r = m - 1; ans = money - (e-m+1)*num - (p[e] - p[m-1]); } else { l = m + 1; } } return {ans, r+1}; }*/ int besthub(int n, int l, int a[], long long b) { /*for (ll i = 0; i<n; i++){ p[i+1] = p[i] + a[i]; }*/ ll mx = 0; for (ll i = 0; i<n; i++){ vector<ll>v; for (ll j = 0; j<i; j++){ v.push_back(a[i] - a[j]); } for (ll j = i; j<n; j++){ v.push_back(a[j] - a[i]); } sort(v.begin(), v.end()); ll sum = 0, cnt = 0; for (ll j = 0; j<v.size(); j++){ sum += v[j]; cnt++; if (sum > b){ cnt--; break; } } mx = max(mx, cnt); } return mx; }

Compilation message (stderr)

ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:57:25: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |         for (ll j = 0; j<v.size(); j++){
      |                        ~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...