Submission #1027079

# Submission time Handle Problem Language Result Execution time Memory
1027079 2024-07-18T20:33:49 Z kkkkkkkk Rice Hub (IOI11_ricehub) C++14
0 / 100
5 ms 860 KB
#include <bits/stdc++.h>

using namespace std;

vector<int> v;
long long B;

bool proveri(int k) {
    for (int i=0;i<v.size()-k;i++) {
        int hub_poz=v[(i+i+k)/2];
        long long zbir=0;
        bool ok=true;
        for (int j=i;j<i+k;j++) {
            zbir+=hub_poz-v[j];
            if (zbir>B) {
                ok=false;
                break;
            }
        }
        if (ok) return true;
    }
    return false;
}

int besthub(int R, int L, int a[], long long b) {
    B=b;
    for (int i=0;i<R;i++)
        v.push_back(a[i]);
    int l=1, r=R+1;
    while (l+1<r) {
        int mid=(l+r)/2;
        if (proveri(mid)) l=mid;
        else r=mid;
    }
    return l;
}

Compilation message

ricehub.cpp: In function 'bool proveri(int)':
ricehub.cpp:9:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 |     for (int i=0;i<v.size()-k;i++) {
      |                  ~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 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 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 860 KB Output isn't correct
2 Halted 0 ms 0 KB -