#include <bits/stdc++.h>
#define dbg(x) cerr << #x << ": " << x << "\n";
using namespace std;
void kadane(const vector<long long> &arr, long long &ans){
long long aux = 0;
for(int i = 0; i < (int)arr.size(); i++){
aux = max(aux + arr[i], arr[i]);
ans = max(ans, aux);
}
}
int main(){
int n;
cin >> n;
vector<long long> x(n), y(n), v(n);
long long ans = 0;
for(int i = 0; i < n; i++) cin >> x[i] >> y[i] >> v[i];
ans = *max_element(v.begin(), v.end());
ans = max(ans, 0ll);
for(int i = 0; i < n - 1; i++){
for(int j = i + 1; j < n; j++){
long long num = (y[i] - y[j]);
long long dem = (x[i] - x[j]);
map<long long, long long> check;
for(int k = 0; k < n; k++){
long long key = dem * (y[k] - y[i]) - num * (x[k] - x[i]);
check[key] += v[k];
}
vector<long long> arr;
for(const auto &[a, b] : check){
arr.push_back(b);
}
kadane(arr, ans);
}
}
cout << ans;
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... |