Submission #860859

# Submission time Handle Problem Language Result Execution time Memory
860859 2023-10-14T16:25:48 Z Huseyn123 Rice Hub (IOI11_ricehub) C++17
68 / 100
1000 ms 3676 KB
#include "ricehub.h"
#include <bits/stdc++.h>
#define MAX 200001
#define INF LLONG_MAX
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define ins insert
#define ff first
#define ss second
#define gett(x,m) get<m>(x)
#define all(a) a.begin(),a.end()
#define lb(a,b) lower_bound(all(a),b)
#define ub(a,b) upper_bound(all(a),b)
#define sortv(a) sort(all(a))
#define sorta(a,sz) sort(a,a+sz)
#define inputar(a,b){\
    for(int i=0;i<b;i++){\
        cin >> a[i];\
    }\
}
#define inputvec(a,b){\
    for(int i=0;i<b;i++){\
        ll num;\
        cin >> num;\
        a.pb(num);\
    }\
}
#define outputar(a,b){\
    for(int i=0;i<b;i++){\
        cout << a[i] << " ";\
    }\
    cout << "\n";\
}
#define outputvec(a){\
    for(auto x:a){\
        cout << x << " ";\
    }\
    cout << "\n";\
}
#define reset(a,n,v){\
    for(int i=0;i<n;i++){\
        a[i]=v;\
    }\
}
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef tuple<ll,ll,ll> tll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef double db;
typedef long double ldb;
inline void USACO(string filename){
  freopen((filename+".in").c_str(),"r",stdin);
  freopen((filename+".out").c_str(),"w",stdout);
}
int Y[MAX],Y1[MAX];
ll f(int h,int x,int y){
	ll res=0;
	ll h1=Y[h];
	if(x>0){
		h1-=Y[x-1];
	}
	ll h2=Y[y]-Y[h];
	res+=(h-x+1)*Y1[h]+h2-(y-h)*Y1[h]-h1;
	return res;
}
int besthub(int R, int L, int X[], long long B)
{
	for(int i=0;i<R;i++){
		Y[i]=X[i];
		Y1[i]=X[i];
	}
	for(int i=1;i<R;i++){
		Y[i]+=Y[i-1];
	}
	int res=0;
	for(int i=0;i<R;i++){
		for(int j=i;j<R;j++){
			if((j-i+1)%2){
				if(f(i+(j-i+1)/2,i,j)<=B){
					res=max(res,j-i+1);
				}
			}
			else{
				if(f(i+(j-i+1)/2,i,j)<=B){
					res=max(res,j-i+1);
				}
				if(f(i+(j-i+1)/2-1,i,j)<=B){
					res=max(res,j-i+1);
				}
			}
		}
	}
	return res;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 0 ms 2396 KB Output is correct
9 Correct 0 ms 2396 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 0 ms 2396 KB Output is correct
13 Correct 0 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 ms 2480 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2392 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 1 ms 2392 KB Output is correct
23 Correct 1 ms 2396 KB Output is correct
24 Correct 1 ms 2396 KB Output is correct
25 Correct 1 ms 2408 KB Output is correct
26 Correct 1 ms 2396 KB Output is correct
27 Correct 1 ms 2396 KB Output is correct
28 Correct 1 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 2 ms 2492 KB Output is correct
4 Correct 2 ms 2504 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 3 ms 2496 KB Output is correct
8 Correct 3 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 2 ms 2396 KB Output is correct
12 Correct 2 ms 2396 KB Output is correct
13 Correct 3 ms 2504 KB Output is correct
14 Correct 3 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 2 ms 2492 KB Output is correct
18 Correct 2 ms 2396 KB Output is correct
19 Correct 3 ms 2396 KB Output is correct
20 Correct 3 ms 2500 KB Output is correct
21 Correct 51 ms 2396 KB Output is correct
22 Correct 51 ms 2396 KB Output is correct
23 Correct 57 ms 2520 KB Output is correct
24 Correct 56 ms 2392 KB Output is correct
25 Correct 56 ms 2392 KB Output is correct
26 Correct 55 ms 2396 KB Output is correct
27 Correct 62 ms 2640 KB Output is correct
28 Correct 54 ms 2392 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 798 ms 2900 KB Output is correct
2 Correct 804 ms 2676 KB Output is correct
3 Execution timed out 1043 ms 3676 KB Time limit exceeded
4 Halted 0 ms 0 KB -