This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
template<class T, class U>
void ckmin(T &a, U b)
{
if (a > b) a = b;
}
template<class T, class U>
void ckmax(T &a, U b)
{
if (a < b) a = b;
}
#define MP make_pair
#define PB push_back
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
#define SZ(x) ((int) (x).size())
#define ALL(x) (x).begin(), (x).end()
#define FOR(i, a, b) for (auto i = (a); i < (b); i++)
#define FORD(i, a, b) for (auto i = (a) - 1; i >= (b); i--)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
const int MAXN = 2013;
struct point
{
ll x, y, w;
};
int N;
point arr[MAXN];
vpl angs;
ll ans;
bool cmp(point a, point b)
{
return a.x < b.x;
}
bool cmpy(point a, point b)
{
return a.y < b.y;
}
void test(ll x, ll y)
{
vpl angs;
FOR(i, 0, N)
{
angs.PB({arr[i].x * x + arr[i].y * y, arr[i].w});
}
sort(ALL(angs));
ll sum = 0;
FOR(i, 0, N)
{
sum += angs[i].se;
if (i != N - 1 && angs[i + 1].fi == angs[i].fi)
{
continue;
}
ckmax(ans, sum);
ckmax(sum, 0);
}
}
int32_t main()
{
cout << fixed << setprecision(12);
cerr << fixed << setprecision(4);
ios_base::sync_with_stdio(false); cin.tie(0);
cin >> N;
FOR(i, 0, N)
{
cin >> arr[i].x >> arr[i].y >> arr[i].w;
ckmax(ans, arr[i].w);
}
test(0, 1);
test(1, 0);
FOR(i, 0, N)
{
FOR(j, i + 1, N)
{
test(arr[i].y - arr[j].y, arr[j].x - arr[i].x);
}
}
cout << ans << '\n';
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |