# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1087528 | Noname_1900 | Rice Hub (IOI11_ricehub) | C++17 | 10 ms | 1884 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "ricehub.h"
#include<bits/stdc++.h>
using namespace std;
int besthub(int R, int L, int X[], long long B)
{
int nbRiz = R, maxPos = L;
long long argent = B;
//vector<pair<int, int>>
int debTaille = 1, finTaille = nbRiz+1;
while(debTaille < finTaille-1)
{
//cout << debTaille << " " << finTaille << " : ";
int milieu = (debTaille+finTaille)/2;
// cout << milieu << endl;
int mediane = X[milieu/2];
bool marche = false;
long long combienCout = 0;
for(int i = 0; i < milieu; i++)
{
combienCout += abs(mediane-X[i]);
}
// cout << mediane<< " " << combienCout << endl;
if(combienCout <= argent)
{
debTaille = milieu;
continue;
}
for(int i = milieu; i < nbRiz; i++)
{
int ancMEdiane = mediane;
combienCout -= abs(ancMEdiane-X[i-milieu]);
mediane = X[(i+(i-milieu+1))/2];
combienCout += abs(mediane-X[i]);
//combienCout += abs(ancMEdiane-mediane);
// |c||||a|||||c|
/// cout << mediane<< " " << combienCout << endl;
if(combienCout <= argent)
{
debTaille = milieu;
marche = true;
break;
}
}
if(!marche)
finTaille = milieu;
}
return debTaille;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |