이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "fish.h"
#include<bits/stdc++.h>
using namespace std;
#define ll long long// !
#define sz(a) (int)a.size()
#define all(a) a.begin(),a.end()
#define F first
#define S second
ll max_weights(int n, int m, vector<int> X, std::vector<int> Y, vector<int> W) {
vector<pair<int, int>> pos[2];
for (int i = 0; i < m; i++){
pos[X[i]].push_back({Y[i], W[i]});
}
sort(all(pos[0]));
sort(all(pos[1]));
ll cnt0 = 0;
for (auto [y, w] : pos[0]) cnt0 += w;
ll cnt1 = 0;
for (auto [y, w] : pos[1]) cnt1 += w;
ll ans = max(cnt0, cnt1);
int p = 0;
ll cnt = 0;
for (auto [y, w] : pos[0]){
while (p < sz(pos[1]) && pos[1][p].F < y){
cnt += pos[1][p].S;
p++;
}
if (y) cnt += w;
ans = max(ans, cnt);
if (!y) cnt += w;
}
for (auto [y, w] : pos[1]){
while (p < sz(pos[0]) && pos[0][p].F < y){
cnt += pos[0][p].S;
p++;
}
if (y) cnt += w;
ans = max(ans, cnt);
if (!y) cnt += w;
}
return ans;
}
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |