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;
#define int long long
vector<int> posx, posy;
int compress(int x, bool X) {
if (X) return lower_bound(begin(posx), end(posx), x) - begin(posx);
return lower_bound(begin(posy), end(posy), x) - begin(posy);
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int q;
cin >> q;
vector<vector<int>> info;
vector<int> prefx(q), prefy(q);
while (q--) {
int x, y, v;
cin >> x >> y >> v;
posx.push_back(x);
posy.push_back(y);
info.push_back({x, y, v});
}
sort(begin(posx), end(posx));
posx.erase(unique(begin(posx), end(posx)), end(posx));
for (auto& i : info) {
prefx[compress(i[0], true)] += i[2];
}
int sm = 0, mn = 0, ans = 0;
for (int i = 0; i < posx.size(); i++) {
sm += prefx[i];
mn = min(mn, sm);
ans = max(ans, sm - mn);
}
cout << ans;
}
Compilation message (stderr)
bulldozer.cpp: In function 'int main()':
bulldozer.cpp:32:23: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
32 | for (int i = 0; i < posx.size(); i++) {
| ~~^~~~~~~~~~~~~
# | 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... |