Submission #1003214

# Submission time Handle Problem Language Result Execution time Memory
1003214 2024-06-20T07:51:56 Z HasanV11010238 Rice Hub (IOI11_ricehub) C++17
17 / 100
1000 ms 860 KB
#include "ricehub.h"
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000000000
using namespace std;
vector<ll> pr, x;
int besthub(int R, int L, int X[], long long B)
{
  pr.assign(R + 1, 0), x.assign(R + 1, 0);
  for (int i = 1; i <= R; i++){
    x[i] = X[i - 1];
    pr[i] = pr[i - 1] + x[i];
  }
  ll ans = 0;
  for (int i = 1; i <= L; i++){
    ll co = 0, dist = INF;
    int in;
    for (int j = 1; j <= R; j++){
      if (abs(x[j] - i) < dist){
        in = j;
        dist = abs(x[j] - i);
      }
    }
    ll l = in, r = in;
    while (true){
      ll col, cor;
      if (l == 1){
        col = INF;
      }
      else{
        col = i - x[l - 1];
      }
      if (r == R){
        cor = INF;
      }
      else{
        cor = x[r + 1] - i;
      }
      if (co + min(col, cor) > B){
        break;
      }
      else if (col < cor){
        co += col;
        l--;
      }
      else{
        co += cor;
        r++;
      }
    }
    ans = max(ans, r - l + 1);
  }
  return ans;
}

Compilation message

ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:24:8: warning: 'in' may be used uninitialized in this function [-Wmaybe-uninitialized]
   24 |     ll l = in, r = in;
      |        ^
# 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 452 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 444 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 0 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 356 KB Output is correct
2 Incorrect 2 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1075 ms 860 KB Time limit exceeded
2 Halted 0 ms 0 KB -