이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "fish.h"
using namespace std;
#include<bits/stdc++.h>
long long subtask1(int N, int M, std::vector<int> X, std::vector<int> Y,
std::vector<int> W){
long long ans=0;
for(int i=0; i<M; i++){
ans+=W[i];
}
return ans;
}
long long subtask2(int N, int M, std::vector<int> X, std::vector<int> Y,
std::vector<int> W){
vector<pair<int,int>> c0;
vector<pair<int,int>> c1;
long long sum0=0;
long long sum1=0;
for(int i=0; i<M; i++){
if(X[i]==0){
c0.push_back({Y[i], W[i]});
sum0+=W[i];
}
else{
c1.push_back({Y[i], W[i]});
sum1+=W[i];
}
}
if(N==2){
return max(sum0, sum1);
}
sort(c1.begin(), c1.end());
sort(c0.begin(), c0.end());
int ans=max(sum0, sum1);
int mom=sum1;
int j=0;
for(int i=0; i<(int)c1.size(); i++){
while(j<(int)c0.size() && c0[j].first<c1[i].first){
mom+=c0[j].second;
j++;
}
ans=max(ans, mom);
mom-=c1[i].second;
}
return ans;
}
long long max_weights(int N, int M, std::vector<int> X, std::vector<int> Y,
std::vector<int> W) {
if(N==1) return 0;
bool sub1=true;
bool sub2=true;
for(int i=0; i<M; i++){
if(X[i]%2==1){
sub1=false;
}
if(X[i]>1){
sub2=false;
}
}
if(sub1){
return subtask1(N, M, X, Y, W);
}
if(sub2){
return subtask2(N, M, X, Y, W);
}
}
컴파일 시 표준 에러 (stderr) 메시지
fish.cpp: In function 'long long int max_weights(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
fish.cpp:84:1: warning: control reaches end of non-void function [-Wreturn-type]
84 | }
| ^
# | 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... |