Submission #1074254

# Submission time Handle Problem Language Result Execution time Memory
1074254 2024-08-25T09:06:56 Z dosts Rice Hub (IOI11_ricehub) C++17
0 / 100
55 ms 1372 KB
#include "ricehub.h"
//Dost SEFEROĞLU
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define os tree<pii,null_type,less<pii>,rb_tree_tag,tree_order_statistics_node_update>
#define inr int32_t
#define pii pair<int,int>
#define ff first
#define ss second
#define sp << " " <<    
#define all(cont) cont.begin(),cont.end()
#define vi vector<int>

inr besthub(inr R, inr L, inr X[], long long B)
{
  vi p(R+1,0);
  for (int i=1;i<=R;i++) p[i] = p[i-1]+X[i-1];
  int l = 1;
  int r = R;
  while (l<=r) {
    int m = (l+r) >> 1;
    os oset;
    for (int j=1;j<=m-1;j++) {
      oset.insert({X[j-1],j-1});
    }
    bool fl = 0;
    for (int j=m;j<=R;j++) {
      oset.insert({X[j-1],j});
      int med = oset.find_by_order(m/2)->first;
      int medidx = j-m+m/2;
      int sag = (p[j]-p[medidx-1])-med*(j-medidx+1);
      int sol = med*(medidx-(j-m+1)+1)-(p[medidx]-p[j-m]);
      if(sol+sag <= B) fl = 1;
      oset.erase(oset.begin());
    }
    if (fl) l = m+1;
    else r = m-1;
  }
  return r;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 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 Correct 1 ms 348 KB Output is correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 34 ms 1372 KB Output is correct
2 Incorrect 55 ms 1372 KB Output isn't correct
3 Halted 0 ms 0 KB -