Submission #1004679

#TimeUsernameProblemLanguageResultExecution timeMemory
1004679hacizadalRice Hub (IOI11_ricehub)C++17
0 / 100
25 ms3028 KiB
#include "ricehub.h" #include <bits/stdc++.h> using namespace std; #define endl '\n' #define ll long long #define pll pair<ll, ll> int besthub(int n, int l, int a[], long long b) { // 0 1 2 3 4 5 ll x = 0; if (n%2==0){ x = a[n/2] + a[n/2-1]; x /= 2; } else { x = a[n/2]; } vector<ll>v; for (ll i = 0; i<n; i++){ v.push_back(abs(x-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; } } return cnt; }

Compilation message (stderr)

ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:25:21: 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]
   25 |     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...