Submission #198960

# Submission time Handle Problem Language Result Execution time Memory
198960 2020-01-28T12:11:46 Z godwind Rice Hub (IOI11_ricehub) C++14
42 / 100
1000 ms 632 KB
// O O O O O O O O O O O O O O O OO O OO O OO O O O TTCH O TTTCH O TTTCH O O O O
#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx")
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stdio.h>
#include <cstdio>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <random>
#include <iomanip>
#include <bitset>
#include <cassert>
// #include "grader.h"

using namespace std;


#define ll long long
#define ld double
#define null NULL
#define prev prev228
#define index index228
#define left left228
#define right right228
#define hash hash228
#define y1 y1228
#define firn(i, n) for (int i = 0; i < (int)n; ++i)
#define forn(i, n) for (int i = 1; i <= (int)n; ++i)
#define endl '\n'


template<typename T> void uin(T &a, T b) {
    if (b < a) a = b;
}

template<typename T> void uax(T &a, T b) {
    if (b > a) a = b;
}

const int N = 100 * 1000 + 228;

long long sum[N];
int x[N];

long long f(int l, int r, int i) {
	long long res = 0LL; 
	res += (sum[r] - sum[i]) - (long long)x[i - 1] * (long long)(r - i);
	res += (long long)x[i - 1] * (long long)(i - l) - (sum[i - 1] - sum[l - 1]);
	return res;
}

int besthub(int n, int L, int X[], long long B){  
	for (int i = 0; i < n; ++i) {
		x[i] = X[i];
	}
	for (int i = 1; i <= n; ++i) {
		sum[i] = sum[i - 1] + x[i - 1];
	}
	int k = 1;
	for (int i = 1; i <= n; ++i) {
		for (int l = i; l; --l) {
			for (int r = i; r <= n; ++r) {
				if (f(l, r, i) <= B) {
					uax(k, r - l + 1);
				}
			}
		}
		// int l = i, r = i;
		// while (l > 1 && r < n && f(l - 1, r + 1, i) <= B) {
		// 	--l;
		// 	++r;
		// }
		// uax(k, r - l + 1);
		// if (r < n && f(l, r + 1, i) <= B) uax(k, r - l + 2);
		// if (l > 1 && f(l - 1, r, i) <= B) uax(k, r - l + 2);
	}
	return k;
}

// int X[N];

// signed main() {
// 	X[0] = 1, X[1] = 2, X[2] = 10, X[3] = 12, X[4] = 14;
// 	cout << besthub(5, 20, X, 6LL) << '\n';
// }







# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 6 ms 376 KB Output is correct
4 Correct 6 ms 376 KB Output is correct
5 Correct 6 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 6 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 6 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 6 ms 376 KB Output is correct
8 Correct 7 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 6 ms 376 KB Output is correct
11 Correct 5 ms 380 KB Output is correct
12 Correct 6 ms 376 KB Output is correct
13 Correct 5 ms 376 KB Output is correct
14 Correct 6 ms 376 KB Output is correct
15 Correct 6 ms 376 KB Output is correct
16 Correct 6 ms 376 KB Output is correct
17 Correct 6 ms 376 KB Output is correct
18 Correct 5 ms 376 KB Output is correct
19 Correct 6 ms 376 KB Output is correct
20 Correct 6 ms 376 KB Output is correct
21 Correct 24 ms 376 KB Output is correct
22 Correct 26 ms 376 KB Output is correct
23 Correct 36 ms 380 KB Output is correct
24 Correct 33 ms 376 KB Output is correct
25 Correct 35 ms 376 KB Output is correct
26 Correct 35 ms 376 KB Output is correct
27 Correct 29 ms 376 KB Output is correct
28 Correct 26 ms 380 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 376 KB Output is correct
2 Correct 6 ms 376 KB Output is correct
3 Correct 191 ms 376 KB Output is correct
4 Correct 177 ms 504 KB Output is correct
5 Correct 27 ms 504 KB Output is correct
6 Correct 23 ms 376 KB Output is correct
7 Correct 163 ms 504 KB Output is correct
8 Correct 158 ms 504 KB Output is correct
9 Correct 25 ms 376 KB Output is correct
10 Correct 29 ms 376 KB Output is correct
11 Correct 87 ms 376 KB Output is correct
12 Correct 84 ms 376 KB Output is correct
13 Correct 236 ms 504 KB Output is correct
14 Correct 238 ms 376 KB Output is correct
15 Correct 27 ms 376 KB Output is correct
16 Correct 26 ms 376 KB Output is correct
17 Correct 124 ms 376 KB Output is correct
18 Correct 138 ms 376 KB Output is correct
19 Correct 235 ms 376 KB Output is correct
20 Correct 232 ms 400 KB Output is correct
21 Execution timed out 1090 ms 376 KB Time limit exceeded
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1080 ms 632 KB Time limit exceeded
2 Halted 0 ms 0 KB -