답안 #1074265

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1074265 2024-08-25T09:11:53 Z dosts 쌀 창고 (IOI11_ricehub) C++17
100 / 100
351 ms 8884 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+1;
      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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 600 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 1 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 1 ms 444 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 444 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 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 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 344 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 2 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 452 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 508 KB Output is correct
18 Correct 1 ms 448 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 9 ms 460 KB Output is correct
22 Correct 9 ms 684 KB Output is correct
23 Correct 9 ms 716 KB Output is correct
24 Correct 9 ms 604 KB Output is correct
25 Correct 8 ms 604 KB Output is correct
26 Correct 8 ms 604 KB Output is correct
27 Correct 8 ms 604 KB Output is correct
28 Correct 9 ms 600 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 36 ms 1368 KB Output is correct
2 Correct 34 ms 1368 KB Output is correct
3 Correct 317 ms 8884 KB Output is correct
4 Correct 302 ms 8784 KB Output is correct
5 Correct 115 ms 2908 KB Output is correct
6 Correct 112 ms 2908 KB Output is correct
7 Correct 351 ms 8788 KB Output is correct
8 Correct 344 ms 8532 KB Output is correct
9 Correct 167 ms 2648 KB Output is correct
10 Correct 175 ms 2652 KB Output is correct
11 Correct 303 ms 8784 KB Output is correct
12 Correct 304 ms 8792 KB Output is correct
13 Correct 109 ms 2908 KB Output is correct
14 Correct 105 ms 2908 KB Output is correct
15 Correct 216 ms 6736 KB Output is correct
16 Correct 222 ms 6740 KB Output is correct
17 Correct 266 ms 7760 KB Output is correct
18 Correct 271 ms 7788 KB Output is correct
19 Correct 284 ms 8336 KB Output is correct
20 Correct 291 ms 8532 KB Output is correct