이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "fish.h"
#include <vector>
#include<bits/stdc++.h>
using namespace std;
long long max_weights(int N, int M, std::vector<int> X, std::vector<int> Y,
std::vector<int> W) {
bool flag = true;
for(auto it:X)
if(it%2)
{
flag = false;
break;
}
if(flag)
{
long long sol = 0;
for(auto it:W)
sol+=it;
return sol;
}
flag = true;
for(auto it:X)
if(it>1)
{
flag = false;
break;
}
if(flag)
{
std::vector<pair<int,int> > y0;
std::vector<pair<int,int> > y1;
int sz = X.size();
for(int i=0;i<sz;i++)
if(X[i]==0) y0.emplace_back(Y[i],W[i]);
else y1.emplace_back(Y[i],W[i]);
std::sort(y0.begin(),y0.end());
std::sort(y1.begin(),y1.end());
long long sol = 0LL;
long long sum = 0LL;
for(auto it:y1)
sum += 1LL*it.second;
sol = sum;
/**
* Pana la un anumit punct luam din 0, apoi din 1
*/
int pnt0 = -1;
int pnt1 = 0;
long long sum0 = 0;
for(int i=0;i<sz;i++)
{
pnt0++;
sum0 += y0[pnt0].second;
while((pnt1+1)<sz && y1[pnt1].first<=y0[pnt0].first)
{
sum -= 1LL * y1[pnt1].second;
pnt1++;
}
sol = max(sol,sum+sum0);
}
return sol;
}
return 0;
}
# | 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... |