#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 mat0[n]={0},mat1[n]={0};
for (int i=0;i<m;i++)
{
if (x[i]==0)
mat0[y[i]]=w[i];
else
mat1[y[i]]=w[i];
}
for (int i=1;i<n;i++)
{
mat0[i]+=mat0[i-1];
mat1[i]+=mat1[i-1];
}
if (n<=2)
vk=max(mat1[n-1],mat0[n-1]);
else
{
vk=mat1[n-1];
for (int i=0;i<n;i++)
vk=max(vk,mat1[n-1]+mat0[i]-mat1[i]);
}
}
return vk;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
30 ms |
3556 KB |
Output is correct |
2 |
Correct |
29 ms |
4192 KB |
Output is correct |
3 |
Correct |
0 ms |
276 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Incorrect |
84 ms |
8812 KB |
1st lines differ - on the 1st token, expected: '149814460735479', found: '49851995244248' |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
49 ms |
5396 KB |
Output is correct |
3 |
Correct |
55 ms |
6476 KB |
Output is correct |
4 |
Correct |
22 ms |
3560 KB |
Output is correct |
5 |
Correct |
28 ms |
4152 KB |
Output is correct |
6 |
Incorrect |
0 ms |
212 KB |
1st lines differ - on the 1st token, expected: '4044', found: '6066' |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
2 ms |
1832 KB |
Output is correct |
3 |
Incorrect |
20 ms |
2852 KB |
1st lines differ - on the 1st token, expected: '21261825233649', found: '774766749' |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Incorrect |
1 ms |
212 KB |
1st lines differ - on the 1st token, expected: '4044', found: '6066' |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Incorrect |
1 ms |
212 KB |
1st lines differ - on the 1st token, expected: '4044', found: '6066' |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Incorrect |
1 ms |
212 KB |
1st lines differ - on the 1st token, expected: '4044', found: '6066' |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
2 ms |
1832 KB |
Output is correct |
3 |
Incorrect |
20 ms |
2852 KB |
1st lines differ - on the 1st token, expected: '21261825233649', found: '774766749' |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
30 ms |
3556 KB |
Output is correct |
2 |
Correct |
29 ms |
4192 KB |
Output is correct |
3 |
Correct |
0 ms |
276 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Incorrect |
84 ms |
8812 KB |
1st lines differ - on the 1st token, expected: '149814460735479', found: '49851995244248' |
6 |
Halted |
0 ms |
0 KB |
- |