# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1087530 | 2024-09-12T21:04:24 Z | Noname_1900 | Rice Hub (IOI11_ricehub) | C++17 | 2 ms | 348 KB |
#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; mediane = X[(i+(i-milieu+1))/2]; combienCout -= abs(mediane-X[i-milieu]); 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
# | 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 | 0 ms | 344 KB | Output isn't correct |
2 | 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 | 2 ms | 344 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |