Submission #335801

# Submission time Handle Problem Language Result Execution time Memory
335801 2020-12-14T03:24:01 Z sumit_kk10 Rice Hub (IOI11_ricehub) C++14
68 / 100
1000 ms 748 KB
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long int
#define ld long double
using namespace std;
const int N = 1e6 + 5;
const int MOD = 1e9 + 7;

long long int besthub(int r, int l, int a[], long long int b){
	long long int ans = 1;
	for(int i = 0; i < r; ++i){
		int j = i - 1, k = i + 1;
		long long int budget = b, how_many = 1;
		while(budget >= 0){
			if(j < 0 and k >= r) break;
			if(abs(a[j] - a[i]) <= abs(a[k] - a[i]) and abs(a[j] - a[i]) <= budget and j >= 0){
				// if(i == 3)
					// cout << a[j] << ' ';
				budget -= abs(a[j] - a[i]);
				++how_many;
				--j;
			}
			else if(abs(a[k] - a[i]) <= abs(a[j] - a[i]) and abs(a[k] - a[i]) <= budget and k < r){
				budget -= abs(a[k] - a[i]);
				++how_many;
				++k;
			}
			else
				break;
		}
		ans = max(ans, how_many);
	}
	return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 384 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
22 Correct 1 ms 364 KB Output is correct
23 Correct 1 ms 364 KB Output is correct
24 Correct 2 ms 364 KB Output is correct
25 Correct 2 ms 364 KB Output is correct
26 Correct 2 ms 364 KB Output is correct
27 Correct 1 ms 364 KB Output is correct
28 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 308 KB Output is correct
3 Correct 2 ms 364 KB Output is correct
4 Correct 2 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 5 ms 364 KB Output is correct
14 Correct 3 ms 364 KB Output is correct
15 Correct 2 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 4 ms 364 KB Output is correct
18 Correct 4 ms 364 KB Output is correct
19 Correct 6 ms 364 KB Output is correct
20 Correct 6 ms 364 KB Output is correct
21 Correct 5 ms 364 KB Output is correct
22 Correct 6 ms 492 KB Output is correct
23 Correct 63 ms 364 KB Output is correct
24 Correct 62 ms 364 KB Output is correct
25 Correct 127 ms 400 KB Output is correct
26 Correct 126 ms 364 KB Output is correct
27 Correct 38 ms 400 KB Output is correct
28 Correct 40 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 364 KB Output is correct
2 Correct 8 ms 364 KB Output is correct
3 Execution timed out 1091 ms 748 KB Time limit exceeded
4 Halted 0 ms 0 KB -