-
-
Save ArthurLoboLobo/cc4785ac221dad87f74af43ff9664226 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
typedef std::pair<int,int> pii; | |
typedef std::pair<double,pii> id; | |
///Função para calcular o seno | |
double calcular(int a,int b) { | |
if(!a||!b)return 0; | |
return (double)a/(double)b; | |
} | |
///Função que determina o quadrante do ponto | |
pii quad(int a,int b) { | |
int x; | |
if(!a)x=2;else if(a>0)x=1;else x=0; | |
int y; | |
if(!b)y=2;else if(b>0)y=1;else y=0; | |
return {x,y}; | |
} | |
const int inf = 99999999999999LL; | |
int main() | |
{ | |
std::ios::sync_with_stdio(false); | |
std::cin.tie(0); | |
std::cout.tie(0); | |
typedef std::pair<pii,int> ppi; | |
int n; | |
std::cin >> n; | |
ppi array[n]; | |
///Lê o input | |
for(int i = 0; i != n;++i) { | |
auto& x = array[i]; | |
std::cin >> x.first.first >> x.first.second >> x.second; | |
} | |
///Sorta os pontos por coordenada X | |
std::sort(array,&array[n]); | |
long long max = -inf; | |
///Itera pelo primeiro ponto da corda | |
for(int i = 0; i != n;++i) { | |
///Map para armazenar o ângulo dos pontos | |
std::map<id,long long> mapa; | |
///Simulamos os pontos para a direita -> isto é, onde é localizado o segundo ponto do barbante | |
for(int j = i+1; j != n;++j){ | |
if(i==j)continue; | |
///Calculamos o ângulo do ponto j em relação ao ponto i | |
int difx = array[i].first.first-array[j].first.first; | |
int dify = array[i].first.second-array[j].first.second; | |
///Armazena o seno | |
auto _ = calcular(abs(difx),abs(dify)); | |
///Armazena o quadrante | |
auto __ = quad(difx,dify); | |
///Armazena a pontuação do ângulo do ponto j | |
auto& ite = mapa[{_,__}]; | |
///Aumenta o map com a pontuaão do ponto j | |
ite += array[j].second; | |
///Armazena o valor da linha entre i e j | |
max = std::max(max,ite+array[i].second); | |
} | |
} | |
///Output da resposta | |
std::cout << max << std::endl; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment