Submission #612276

# Submission time Handle Problem Language Result Execution time Memory
612276 2022-07-29T12:33:17 Z cheissmart Seesaw (JOI22_seesaw) C++14
34 / 100
2000 ms 94532 KB
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(v) int((v).size())
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;
typedef long double db;

string _reset = "\u001b[0m", _yellow = "\u001b[33m", _bold = "\u001b[1m";
void DBG() { cerr << "]" << _reset << endl; }
template<class H, class...T> void DBG(H h, T ...t) {
	cerr << to_string(h);
	if(sizeof ...(t)) cerr << ", ";
	DBG(t...);
}
#ifdef CHEISSMART
#define debug(...) cerr << _yellow << _bold << "Line(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__)
#else
#define debug(...)
#endif

const int INF = 1e9 + 7, N = 2e5 + 6;
const ll oo = 1e18;

int a[N];
ll p[N];

signed main()
{
	IO_OP;

	cout << fixed << setprecision(12);

	int n;
	cin >> n;
	for(int i = 1; i <= n; i++) {
		cin >> a[i];
		p[i] = p[i - 1] + a[i];
	}
	V<db> aux;
	for(int i = 1; i <= n; i++) {
		for(int j = i; j <= n; j++) {
			aux.PB(db(p[j] - p[i - 1]) / (j - i + 1));
		}
	}
	sort(ALL(aux));
	db ans = oo;
	for(db mn:aux) {
		V<V<db>> dp(n + 1, V<db>(n + 1, oo));
		for(int len = 1; len <= n; len++) {
			for(int i = 1; i + len - 1 <= n; i++) {
				int j = i + len - 1;
				db tt = db(p[j] - p[i - 1]) / (j - i + 1);
				if(tt >= mn) {
					if(i == j)
						dp[i][j] = tt;
					else {
						dp[i][j] = max(min(dp[i][j - 1], dp[i + 1][j]), tt);
					}
				}
			}
		}
		ans = min(ans, dp[1][n] - mn);
	}
	cout << ans << '\n';
}

# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 228 ms 564 KB Output is correct
5 Correct 233 ms 468 KB Output is correct
6 Correct 216 ms 572 KB Output is correct
7 Correct 231 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 228 ms 564 KB Output is correct
5 Correct 233 ms 468 KB Output is correct
6 Correct 216 ms 572 KB Output is correct
7 Correct 231 ms 468 KB Output is correct
8 Execution timed out 2064 ms 94532 KB Time limit exceeded
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 228 ms 564 KB Output is correct
5 Correct 233 ms 468 KB Output is correct
6 Correct 216 ms 572 KB Output is correct
7 Correct 231 ms 468 KB Output is correct
8 Execution timed out 2064 ms 94532 KB Time limit exceeded
9 Halted 0 ms 0 KB -