| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1346920 | michael12 | Rice Hub (IOI11_ricehub) | C++20 | 0 ms | 0 KiB |
#include "ricehub.h"
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<numeric>
#include<string>
#include<stack>
#include<queue>
#include<string.h>
#include<array>
#include<climits>
#include<algorithm>
#include<cmath>
using namespace std;
#define ff first
#define ss second
#define ll long long
#define endl '\n'
const int maxn = 5e5;
int besthub(int R, int L, int x1[], int B){
ll mx = 0;
vector<int> x(R);
for(int i = 0; i < R; i++){
x[i] = x1[i];
}
for(int i = 0; i < R; i++){
ll cur = 0;
int cnt = 0;
int low = i;
int high = i;
while(cur <= B){
if(low > 0 && high < R - 1){
if(abs(x[low] - x[i]) > abs(x[high] - x[i])){
high += 1;
cnt += 1;
cur += abs(x[high] - x[i]);
}
else{
low -= 1;
cnt += 1;
cur += abs(x[low] - x[i]);
}
}
else if(low > 0){
low -= 1;
cnt += 1;
cur += abs(x[low] - x[i]);
}
else{
high += 1;
cnt += 1;
cur += abs(x[high] - x[i]);
}
}
mx = max(1LL * cnt, mx);
// X[i]
}
return mx;
}
// signed main(){
// int R, L, B;
// cin >> R >> L >> B;
// int X[R];
// for(int i = 0; i < R; i++){
// cin >> X[i];
// }
// int a = besthub(R, L, X, B);
// cout << a;
// }
