이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
struct fish{fish(int xi,int yi,int wi):x(xi),y(yi),w(wi){} int x,y,w;};
ll max_weights(int N,int M,vector<int> X,vector<int> Y,vector<int> W) {
if(N==2) {
ll c1=0,c2=0;
for(int i=0;i<M;++i) {
if(X[i]==0) c1+=W[i];
else c2+=W[i];
}
return max(c1,c2);
} else {
vector<fish> v;
ll tot=0;
for(int i=0;i<M;++i) {
v.push_back(fish(X[i],Y[i],W[i]));
if(X[i]==1) tot+=W[i];
}
ll ans=tot;
sort(v.begin(),v.end(),[](fish a,fish b) {return (a.y==b.y?a.x>b.x:a.y<b.y);});
for(fish f:v) {
if(f.x==1) tot-=f.w;
else tot+=f.w;
ans=max(ans,tot);
}
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... |