Submission #575194

# Submission time Handle Problem Language Result Execution time Memory
575194 2022-06-09T21:32:13 Z d4xn Mountains (IOI17_mountains) C++17
20 / 100
1 ms 356 KB
#pragma GCC optimize ("Ofast")
#include "mountains.h"
#include <bits/stdc++.h>
using namespace std;

#define ld long double
#define ll long long

const int N = 2002;

int n, ans;
vector<int> dp[N];

int maximum_deevs(vector<int> y) {
	n = y.size();
	ans = 0;
	for (int i = 0; i < n; i++) {
		dp[i].push_back(i);

		for (int j = 0; j < i; j++) {
			bool ok = 1;

			for (int idx : dp[j]) {
				if (!ok) break;

				bool ok2 = 0;

				for (int k = idx+1; k < i; k++) {
					ld a = i;
					ld b = idx;
					ld c = k;
					ld d = y[i];
					ld e = y[idx];
					ld f = y[k];

					ld p = (d-e) / (a-b);
					ld h = e + ((c-b) * p);

					if (f > h) {
						ok2 = 1;
						break;
					}
				}
				if (!ok2) ok = 0;
			}

			if (ok) {
				if (dp[j].size()+1 > dp[i].size()) {
					dp[i] = dp[j];
					dp[i].push_back(i);
				}
			}
		}
		int sz = dp[i].size();
		ans = max(ans, sz);
	}
	return max(ans, 1);
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 352 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 352 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 352 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 352 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 0 ms 340 KB Output is correct
20 Correct 1 ms 352 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 356 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 352 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Incorrect 1 ms 340 KB Output isn't correct
31 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 352 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 352 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 0 ms 340 KB Output is correct
20 Correct 1 ms 352 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 356 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 352 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Incorrect 1 ms 340 KB Output isn't correct
31 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 352 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 352 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 0 ms 340 KB Output is correct
20 Correct 1 ms 352 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 356 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 352 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Incorrect 1 ms 340 KB Output isn't correct
31 Halted 0 ms 0 KB -