Submission #788772

# Submission time Handle Problem Language Result Execution time Memory
788772 2023-07-20T15:02:35 Z Ronin13 Rice Hub (IOI11_ricehub) C++17
100 / 100
19 ms 2520 KB
#include "ricehub.h"
#include <bits/stdc++.h>
#define ll long long 
#define ull unsigned ll
#define f first
#define s second
#define pii pair<int, int>
#define pll pair<ll,ll>
#define pb push_back
#define epb emplace_back
using namespace std;

int besthub(int n, int l, int X[], long long B){
      ll pref[n + 1];
      pref[0] = 0;
      for(int i = 1; i <= n; i++){
          pref[i] = pref[i - 1] + (ll)X[i - 1];
      }
      
      int mx = 0;
      for(int i = 1; i <= n; i++){
          int l = 0, r = n + 1;
          while(l + 1 < r){
              int mid = (l + r) / 2;
              int x = (mid + 1) / 2;
              int y = mid - x;
              if(i < x) {
                  r = mid;
                  continue;
              } 
              if(i + y > n){
                  r = mid;
                  continue;
              }
              ll a = (ll)x * (ll)X[i - 1] - (pref[i] - pref[i - x]);
              ll b = pref[i + y] - pref[i] - (ll)X[i - 1] * (ll)y;
              if(a + b <= B) l = mid;
              else r = mid;
          }
          //cout << l << ' ';
          mx = max(mx, l);
      }
      return mx;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 264 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 312 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 312 KB Output is correct
17 Correct 1 ms 308 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 312 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 316 KB Output is correct
13 Correct 1 ms 312 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 324 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 344 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 320 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 352 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 468 KB Output is correct
2 Correct 2 ms 540 KB Output is correct
3 Correct 19 ms 1484 KB Output is correct
4 Correct 15 ms 2516 KB Output is correct
5 Correct 7 ms 1236 KB Output is correct
6 Correct 6 ms 1224 KB Output is correct
7 Correct 14 ms 2208 KB Output is correct
8 Correct 14 ms 2232 KB Output is correct
9 Correct 6 ms 1192 KB Output is correct
10 Correct 7 ms 1188 KB Output is correct
11 Correct 15 ms 2520 KB Output is correct
12 Correct 15 ms 2516 KB Output is correct
13 Correct 6 ms 1220 KB Output is correct
14 Correct 9 ms 1268 KB Output is correct
15 Correct 11 ms 1964 KB Output is correct
16 Correct 11 ms 1864 KB Output is correct
17 Correct 14 ms 2220 KB Output is correct
18 Correct 15 ms 2260 KB Output is correct
19 Correct 14 ms 2316 KB Output is correct
20 Correct 14 ms 2348 KB Output is correct