Submission #1087528

# Submission time Handle Problem Language Result Execution time Memory
1087528 2024-09-12T20:58:27 Z Noname_1900 Rice Hub (IOI11_ricehub) C++17
0 / 100
10 ms 1884 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;
          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

ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:6:18: warning: unused variable 'maxPos' [-Wunused-variable]
    6 |   int nbRiz = R, maxPos = L;
      |                  ^~~~~~
# 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 1 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 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Incorrect 0 ms 348 KB Output isn't correct
20 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 452 KB Output is correct
4 Correct 1 ms 456 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Incorrect 0 ms 348 KB Output isn't correct
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 604 KB Output is correct
2 Correct 2 ms 496 KB Output is correct
3 Correct 10 ms 1880 KB Output is correct
4 Correct 9 ms 1884 KB Output is correct
5 Correct 5 ms 860 KB Output is correct
6 Correct 6 ms 824 KB Output is correct
7 Correct 9 ms 1488 KB Output is correct
8 Correct 9 ms 1552 KB Output is correct
9 Correct 4 ms 860 KB Output is correct
10 Correct 6 ms 688 KB Output is correct
11 Correct 10 ms 1884 KB Output is correct
12 Correct 9 ms 1668 KB Output is correct
13 Correct 5 ms 860 KB Output is correct
14 Incorrect 5 ms 860 KB Output isn't correct
15 Halted 0 ms 0 KB -