이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
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);
}
int 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));
sort(begin(posy), end(posy));
posx.erase(unique(begin(posx), end(posx)), end(posx));
posy.erase(unique(begin(posy), end(posy)), end(posy));
for (auto& i : info) {
prefx[compress(i[0], true)] += i[2];
prefy[compress(i[1], false)] += 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);
}
sm = 0, mn = 0;
for (int i = 0; i < posy.size(); i++) {
sm += prefy[i];
mn = min(mn, sm);
ans = max(ans, sm - mn);
}
cout << ans;
}
컴파일 시 표준 에러 (stderr) 메시지
bulldozer.cpp: In function 'int main()':
bulldozer.cpp:35:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
35 | for (int i = 0; i < posx.size(); i++) {
| ~~^~~~~~~~~~~~~
bulldozer.cpp:41:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
41 | for (int i = 0; i < posy.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... |