Submission #1199309

#TimeUsernameProblemLanguageResultExecution timeMemory
1199309agussBulldozer (JOI17_bulldozer)C++20
5 / 100
41 ms328 KiB
#include <bits/stdc++.h> #define dbg(x) cerr << #x << ": " << x << "\n"; using namespace std; void kadane(const map<long long, long long> &arr, long long &ans){ long long aux = 0; for(const auto &i : arr){ aux = max(aux + i.second, i.second); ans = max(ans, aux); } } int main(){ int n; cin >> n; vector<long long> x(n), y(n), v(n); long long ans; 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]); if(!num or !dem) continue; map<long long, long long> check; for(int k = 0; k < n; k++){ long long key = dem * y[k] - num * x[k]; check[key] += v[k]; } kadane(check, ans); } } map<long long, long long> ver, hor; for(int i = 0; i < n; i++){ ver[y[i]] += v[i]; hor[x[i]] += v[i]; } kadane(ver, ans); kadane(hor, ans); cout << ans; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...