Submission #1004679

# Submission time Handle Problem Language Result Execution time Memory
1004679 2024-06-21T12:23:53 Z hacizadal Rice Hub (IOI11_ricehub) C++17
0 / 100
25 ms 3028 KB
#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

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 time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Incorrect 0 ms 348 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 856 KB Output is correct
2 Correct 3 ms 860 KB Output is correct
3 Correct 25 ms 3028 KB Output is correct
4 Correct 16 ms 3028 KB Output is correct
5 Incorrect 5 ms 1488 KB Output isn't correct
6 Halted 0 ms 0 KB -