Submission #1003243

# Submission time Handle Problem Language Result Execution time Memory
1003243 2024-06-20T08:10:30 Z ayankarimova Rice Hub (IOI11_ricehub) C++14
0 / 100
17 ms 868 KB
#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], d[sz], s[sz];
int besthub(int r, int l, int x[], long long k)
{
    sort(x, x+r);
    for(int i=1; i<=l; i++){
        for(int j=0; j<r; j++){
            if(i<x[j])  break;
            d[i]+=i-x[j];
        }
        //cout<<d[i]<<' ';
    }
    for(int i=0; i<r; i++) s[x[i]]++;
    for(int i=1; i<=l; i++) s[i]+=s[i-1];
    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=(d[m]-d[x[i]])-i*(m-x[i]);
            ll num2=(d[x[j]]-d[m])-(s[m]-1)*(x[j]-m);
            if(i==j) cout<<num1<<' '<<num2<<endl;
            if(num1+num2<=k){
                ans=max(ans, (ll)j-i+1);
                //cout<<i<<' '<<j<<' '<<num1<<' '<<num2<<' '<<ans<<endl;
            }
        }
    }
    return ans;
}
/*
{} []
5 20 6

1 2 10 12 14 3
*/
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 17 ms 868 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -