This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
long long max_weights(int n,int m,vector<int> x,vector<int> y,vector<int> w)
{
long long vk=0;
bool first=true;
for (int i=0;i<m;i++)
if (w[i]%2==1)
{
first=false;
break;
}
if (first)
{
for (int i=0;i<m;i++)
vk+=w[i];
}
else
{
long long mat[n][2];
memset(mat,0,sizeof(mat));
for (int i=0;i<m;i++)
{
if (x[i]==0)
mat[y[i]][0]=w[i];
else
vk+=w[i],mat[y[i]][1]=w[i];
}
for (int i=n-2;i>=0;i--)
{
mat[i][0]+=mat[i+1][0];
mat[i][1]+=mat[i+1][1];
vk=max(vk,vk+mat[i][0]-mat[i][1]);
}
}
return vk;
}
# | 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... |