Submission #788303

# Submission time Handle Problem Language Result Execution time Memory
788303 2023-07-20T05:26:16 Z mindiyak Rice Hub (IOI11_ricehub) C++14
17 / 100
469 ms 262144 KB
#include "ricehub.h"
#include <iostream>
#include <vector>
#include <set>

using namespace std;

#define ll long long

int besthub(int R, int L, int X[], long long B)
{
  ll ans = 0;
  vector<multiset<int>> pos(L+1,multiset<int>());
  for(ll i=0;i<R;i++){
    // cout << max((ll)1,X[i]-B) << " " << min((ll)L,X[i]+B) << endl;
    for(ll j=max((ll)1,X[i]-B);j<=min((ll)L,X[i]+B);j++){
      // cout << j << " " << abs(X[i]-j) << endl;
      pos[j].insert(abs(X[i]-j));
    }
    // cout << endl;
  }

  // cout << endl;

  // for(ll i=1;i<=L;i++){
  //   cout << i << " -> ";
  //   for(ll j:pos[i]){
  //       cout << j << " ";
  //   }
  //   cout << endl;
  // }

  // cout << endl;

  for(ll i=1;i<=L;i++){
    ll sum = 0;
    ll counter = 0;
    // cout << i << " " << pos[i].size() << " ";
    bool all = true;
    for(ll j:pos[i]){
      sum += j;
      if(sum>=B){
        all = false;
        // cout << " " << sum << " " << counter;
        ans = max(ans,counter);
        break;
      }
      counter++;
    }
    if(all){
      ans = max(ans,(ll)pos[i].size());
    }
    // cout << endl;
  }
  // cout << ans << endl;
  return ans;
}

# Verdict Execution time Memory Grader output
1 Correct 1 ms 292 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 596 KB Output is correct
5 Correct 1 ms 568 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 308 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 229 ms 79312 KB Output is correct
2 Correct 223 ms 79096 KB Output is correct
3 Runtime error 236 ms 262144 KB Execution killed with signal 9
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 469 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -