Submission #557177

# Submission time Handle Problem Language Result Execution time Memory
557177 2022-05-04T20:23:24 Z n0sk1ll Rice Hub (IOI11_ricehub) C++14
17 / 100
14 ms 1760 KB
#include "ricehub.h"
#include<bits/stdc++.h>

using namespace std;
long long int typedef li;

int besthub(int n, int m, int x[], li b)
{
    int mx=0; li balans=0;
    int l=0,r=0;
    for (int i=0;i<n;i++) if (balans+(x[i]-x[0])<=b) balans+=(x[i]-x[0]),r++;
    //cout<<0<<": "<<"["<<l<<","<<r<<") - "<<balans<<endl;
    for (int i=1;i<n;i++)
    {
        balans+=(li)(i-l)*(x[i]-x[i-1]);
        balans-=(li)(r-i)*(x[i]-x[i-1]);
        //cout<<i<<": "<<"["<<l<<","<<r<<") - "<<balans<<endl;
        while (balans>b) balans-=(x[i]-x[l]),l++;
        while (r<n && balans+(x[r]-x[i])<=b) balans+=(x[r]-x[i]),r++;
        mx=max(mx,r-l);
        //cout<<i<<": "<<"["<<l<<","<<r<<") - "<<balans<<endl;
        //cout<<endl;
    }
    return mx;
}

/*
5 20 6
1
2
10
12
14
3
*/
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Incorrect 1 ms 212 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Incorrect 1 ms 212 KB Output isn't correct
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 340 KB Output is correct
2 Correct 3 ms 448 KB Output is correct
3 Correct 14 ms 1760 KB Output is correct
4 Correct 14 ms 1704 KB Output is correct
5 Correct 6 ms 852 KB Output is correct
6 Correct 5 ms 852 KB Output is correct
7 Correct 11 ms 1380 KB Output is correct
8 Correct 10 ms 1476 KB Output is correct
9 Correct 5 ms 724 KB Output is correct
10 Correct 5 ms 724 KB Output is correct
11 Correct 13 ms 1740 KB Output is correct
12 Correct 13 ms 1680 KB Output is correct
13 Incorrect 6 ms 808 KB Output isn't correct
14 Halted 0 ms 0 KB -