Submission #1195417

#TimeUsernameProblemLanguageResultExecution timeMemory
1195417agussBulldozer (JOI17_bulldozer)C++20
5 / 100
0 ms580 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; void solve(){ int n; cin >> n; map<int, int> posx, posy; vector<int> x(n), y(n), w(n); for(int i = 0; i < n; i++){ cin >> x[i] >> y[i] >> w[i]; posx[x[i]] = 0; posy[y[i]] = 0; } int xc = 0, yc = posy.size(); for(auto &[i, j] : posx) j = xc++; for(auto &[i, j] : posy) j = --yc; vector<vector<ll>> arr(posy.size(), vector<ll>(posx.size())), pref(posy.size() + 1, vector<ll>(posx.size() + 1)); for(int i = 0; i < n; i++){ arr[posy[y[i]]][posx[x[i]]] = w[i]; } for(int i = 1; i <= posy.size(); i++){ for(int j = 1; j <= posx.size(); j++){ pref[i][j] = pref[i - 1][j] + pref[i][j - 1] + arr[i - 1][j - 1] - pref[i - 1][j - 1]; } } ll ans = 0; for(int i = 1; i <= posy.size(); i++){ for(int j = i; j <= posy.size(); j++){ ll q = pref[j][posx.size()] - pref[i - 1][posx.size()]; ans = max(ans, q); } } for(int i = 1; i <= posx.size(); i++){ for(int j = i; j <= posx.size(); j++){ ll q = pref[posy.size()][j] - pref[posy.size()][i - 1]; ans = max(ans, q); } } cout << ans; } int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); solve(); 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...