Submission #1036212

# Submission time Handle Problem Language Result Execution time Memory
1036212 2024-07-27T05:30:36 Z HappyCapybara Rice Hub (IOI11_ricehub) C++17
49 / 100
10 ms 2684 KB
#include "ricehub.h"
#include<bits/stdc++.h>
using namespace std;

#define ll long long

int besthub(int R, int L, int X[], ll B){
  queue<ll> l, r;
  for (int i=0; i<R; i++) r.push(X[i]);

  int bsf = 0, curl = 0, curr = 0, i = 0;
  ll k = 0;
  while (true){
    //cout << k << " " << r.front() << " " << X[i] << " " << B << "\n";
    while (!r.empty() && ((k+(r.front()-(ll) X[i])) <= B)){
      //cout << "a\n";
      k += r.front()- (ll) X[i];
      l.push(r.front());
      r.pop();
      curr++;
    }
    while (!l.empty() && !r.empty() && curl && (r.front()-X[i]) < (X[i]-l.front())){
      //cout << "b\n";
      k += r.front()+l.front()-2ll* (ll) X[i];
      l.pop();
      l.push(r.front());
      r.pop();
      curl--;
      curr++;
    }
    //cout << k << " " << r.front() << " " << X[i] << " " << B << "\n";
    while (!r.empty() && ((k+(r.front()-(ll) X[i])) <= B)){
      //cout << "a\n";
      k += r.front()- (ll) X[i];
      l.push(r.front());
      r.pop();
      curr++;
    }
    if (k <= B) bsf = max(bsf, curl+curr);
    //cout << i << " " << curl << " " << curr << " " << k << " " << bsf << "\n";
    i++;
    if (i == R) break;
    curl++; curr--;
    k += (ll) (curl-curr) * (ll) (X[i]-X[i-1]);
  }

  return bsf;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 448 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
# Verdict Execution time Memory 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 348 KB Output is correct
5 Correct 1 ms 444 KB Output is correct
6 Correct 0 ms 440 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 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 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 604 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 0 ms 348 KB Output is correct
22 Correct 0 ms 344 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Incorrect 0 ms 348 KB Output isn't correct
28 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 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 448 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 0 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Incorrect 0 ms 348 KB Output isn't correct
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 604 KB Output is correct
2 Correct 2 ms 604 KB Output is correct
3 Correct 9 ms 2652 KB Output is correct
4 Correct 9 ms 2684 KB Output is correct
5 Correct 8 ms 1236 KB Output is correct
6 Correct 4 ms 1372 KB Output is correct
7 Correct 8 ms 2276 KB Output is correct
8 Correct 9 ms 2392 KB Output is correct
9 Correct 4 ms 1116 KB Output is correct
10 Correct 4 ms 1112 KB Output is correct
11 Correct 9 ms 2652 KB Output is correct
12 Correct 10 ms 2596 KB Output is correct
13 Correct 5 ms 1372 KB Output is correct
14 Correct 4 ms 1372 KB Output is correct
15 Correct 7 ms 2088 KB Output is correct
16 Correct 7 ms 2140 KB Output is correct
17 Correct 8 ms 2376 KB Output is correct
18 Correct 9 ms 2492 KB Output is correct
19 Correct 9 ms 2396 KB Output is correct
20 Correct 9 ms 2540 KB Output is correct