답안 #692296

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
692296 2023-02-01T10:10:01 Z zeroesandones Mountains (IOI17_mountains) C++17
0 / 100
0 ms 212 KB
#include <bits/stdc++.h>
#include "mountains.h"
using namespace std;

using ll = long long;
using ld = long double;
using vi = vector<ll>;

bool check(int x, int y, int a, int b, int _a, int _b) {
	ld A = (ld) (a - _a);
	ld B = (ld) (_b - b);
	ld C = (ld) (b * (_a - a) + a * (b - _b));
	ld res = A * y + B * x + C;
	return res > 0;
}

int maximum_deevs(vector<int> y) {
	int n = y.size();
	int ans = 1;

	for(int i = 0; i < (1<<n); ++i) {
		vi subset;
		for(int j = 0; j < n; ++j) {
			if(i & (1<<j))
				subset.emplace_back(j);
		}

		bool valid = true;
		int m = subset.size();
		sort(subset.begin(), subset.end());
		for(int j = 0; j < m - 1; ++j) {
			bool bigger = false;
			for(int x = subset[j] + 1; x < subset[j + 1]; ++x) {
				if(check(x, y[x], subset[j], y[subset[j]], subset[j + 1], y[subset[j + 1]])) {
					bigger = true;
					break;
				}
			}
			if(!bigger) {
				valid = false;
				break;
			}
		}

		if(valid)
			ans = max(ans, m);
	}

	return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -