# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1003175 | ayankarimova | Rice Hub (IOI11_ricehub) | C++14 | 29 ms | 15196 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "ricehub.h"
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long
const ll sz=5005;
ll a[sz], b[sz], s1[sz], s2[sz], s[sz];
map<ll, ll>mp;
int besthub(int r, int l, int x[], long long k)
{
for(int i=0; i<r; i++){
mp[x[i]]++;
s[x[i]]++;
}
for(int i=1; i<=l+1; i++) s[i]+=s[i-1];
ll sum=0;
for(ll i=1; i<=l; i++){
a[i]=a[i-1]+s1[i-1];
s1[i]=mp[i]+s1[i-1];
}
//cout<<endl;
sum=0;
for(ll i=l; i>=1; i--){
b[i]=b[i+1]+s2[i+1];
s2[i]=mp[i]+s2[i+1];
//cout<<b[i]<<' ';
}
ll ans=0;
for(int i=0; i<r; i++){
for(int j=0; j<r; j++){
ll m=(x[i]+x[j])/2;
ll num1=a[m]-a[x[i]]-s1[x[i]-1];
ll num2=b[m]-b[x[j]]-s2[x[j]+1];
if(num1+num2<=k) ans=max(ans, s[x[j]]-s[x[i]-1]);
}
}
return ans;
}
/*
{} []
5 20 6
1 2 10 12 14 3
*/
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |