Submission #557178

# Submission time Handle Problem Language Result Execution time Memory
557178 2022-05-04T20:26:22 Z n0sk1ll Rice Hub (IOI11_ricehub) C++14
17 / 100
16 ms 704 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++) if (x[i]!=x[i-1])
    {
        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 1 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 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 0 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 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 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 1 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Incorrect 0 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 340 KB Output is correct
3 Correct 11 ms 656 KB Output is correct
4 Correct 10 ms 596 KB Output is correct
5 Correct 4 ms 468 KB Output is correct
6 Correct 7 ms 468 KB Output is correct
7 Correct 10 ms 596 KB Output is correct
8 Correct 16 ms 596 KB Output is correct
9 Correct 5 ms 468 KB Output is correct
10 Correct 5 ms 468 KB Output is correct
11 Correct 11 ms 704 KB Output is correct
12 Correct 12 ms 664 KB Output is correct
13 Incorrect 5 ms 468 KB Output isn't correct
14 Halted 0 ms 0 KB -