Submission #903882

# Submission time Handle Problem Language Result Execution time Memory
903882 2024-01-11T13:09:30 Z oblantis Rice Hub (IOI11_ricehub) C++17
100 / 100
16 ms 4456 KB
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#pragma GCC optimize("O3,unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include "ricehub.h"
#define all(v) v.begin(), v.end()
#define pb push_back
#define ss second
#define ff first
#define vt vector
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int, int> pii;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int inf = 1e9;
const int mod = 1e9+7;
const int maxn = 1e5 + 1;
int besthub(int n, int L, int x[], long long b){
	int xl = 1, xr = n + 1;
	ll p[n];
	for(int i = 0; i < n; i++){
		p[i] = x[i];
		if(i)p[i] += p[i - 1];
	}
	while(xl + 1 < xr){
		bool ok = 0;
		int mid = xl + (xr - xl) / 2;
		for(int i = mid - 1; i < n; i++){
			int j = i - mid / 2;
			ll s = p[i] - p[j] * 2;
			if(i != mid - 1)s += p[i - mid];
			if(mid % 2)s += x[j];
			if(s <= b)ok = 1;
		}
		if(ok)xl = mid;
		else xr = mid;
	}
	return xl;
}

//void solve() {
	//int n, l, b;
	//cin >> n >> l >> b;
	//int x[n];
	//for(int i = 0; i < n; i++)cin >> x[i];
	//cout << besthub(n, l, x, b);
//}
//int main() {
	//ios_base::sync_with_stdio(0);
	//cin.tie(0);
	//int times = 1;
	////cin >> times;
	//for(int i = 1; i <= times; i++) {
		//solve();
	//}
	//return 0;
//}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 608 KB Output is correct
3 Correct 0 ms 452 KB Output is correct
4 Correct 0 ms 352 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 356 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 452 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 352 KB Output is correct
11 Correct 1 ms 352 KB Output is correct
12 Correct 0 ms 352 KB Output is correct
13 Correct 1 ms 352 KB Output is correct
14 Correct 0 ms 352 KB Output is correct
15 Correct 0 ms 352 KB Output is correct
16 Correct 1 ms 352 KB Output is correct
17 Correct 1 ms 356 KB Output is correct
18 Correct 0 ms 352 KB Output is correct
19 Correct 1 ms 356 KB Output is correct
20 Correct 0 ms 360 KB Output is correct
21 Correct 1 ms 360 KB Output is correct
22 Correct 0 ms 360 KB Output is correct
23 Correct 0 ms 360 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 1 ms 444 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 456 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 1 ms 600 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 604 KB Output is correct
2 Correct 3 ms 604 KB Output is correct
3 Correct 16 ms 4444 KB Output is correct
4 Correct 10 ms 4456 KB Output is correct
5 Correct 5 ms 3176 KB Output is correct
6 Correct 5 ms 3284 KB Output is correct
7 Correct 8 ms 4200 KB Output is correct
8 Correct 8 ms 4188 KB Output is correct
9 Correct 5 ms 3164 KB Output is correct
10 Correct 6 ms 3164 KB Output is correct
11 Correct 13 ms 4448 KB Output is correct
12 Correct 10 ms 4444 KB Output is correct
13 Correct 5 ms 3420 KB Output is correct
14 Correct 5 ms 3416 KB Output is correct
15 Correct 8 ms 3932 KB Output is correct
16 Correct 10 ms 4024 KB Output is correct
17 Correct 8 ms 4176 KB Output is correct
18 Correct 9 ms 4188 KB Output is correct
19 Correct 9 ms 4184 KB Output is correct
20 Correct 9 ms 4188 KB Output is correct