#include <iostream>
#include <vector>
#include<map>
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 (x[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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
18 ms |
3668 KB |
Output is correct |
2 |
Correct |
23 ms |
4288 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
76 ms |
13776 KB |
Output is correct |
6 |
Correct |
72 ms |
13904 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
37 ms |
8236 KB |
Output is correct |
3 |
Correct |
44 ms |
10064 KB |
Output is correct |
4 |
Correct |
22 ms |
3656 KB |
Output is correct |
5 |
Correct |
23 ms |
4432 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
344 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
20 ms |
5140 KB |
Output is correct |
13 |
Correct |
23 ms |
5948 KB |
Output is correct |
14 |
Correct |
20 ms |
4956 KB |
Output is correct |
15 |
Correct |
22 ms |
5724 KB |
Output is correct |
16 |
Correct |
20 ms |
4980 KB |
Output is correct |
17 |
Correct |
21 ms |
5460 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
2092 KB |
Output is correct |
3 |
Incorrect |
14 ms |
3800 KB |
1st lines differ - on the 1st token, expected: '21261825233649', found: '774766749' |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
436 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Incorrect |
1 ms |
348 KB |
1st lines differ - on the 1st token, expected: '216624184325', found: '2268305442' |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
436 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Incorrect |
1 ms |
348 KB |
1st lines differ - on the 1st token, expected: '216624184325', found: '2268305442' |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
436 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Incorrect |
1 ms |
348 KB |
1st lines differ - on the 1st token, expected: '216624184325', found: '2268305442' |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
2092 KB |
Output is correct |
3 |
Incorrect |
14 ms |
3800 KB |
1st lines differ - on the 1st token, expected: '21261825233649', found: '774766749' |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
18 ms |
3668 KB |
Output is correct |
2 |
Correct |
23 ms |
4288 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
76 ms |
13776 KB |
Output is correct |
6 |
Correct |
72 ms |
13904 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
37 ms |
8236 KB |
Output is correct |
9 |
Correct |
44 ms |
10064 KB |
Output is correct |
10 |
Correct |
22 ms |
3656 KB |
Output is correct |
11 |
Correct |
23 ms |
4432 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
344 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
20 ms |
5140 KB |
Output is correct |
19 |
Correct |
23 ms |
5948 KB |
Output is correct |
20 |
Correct |
20 ms |
4956 KB |
Output is correct |
21 |
Correct |
22 ms |
5724 KB |
Output is correct |
22 |
Correct |
20 ms |
4980 KB |
Output is correct |
23 |
Correct |
21 ms |
5460 KB |
Output is correct |
24 |
Correct |
1 ms |
344 KB |
Output is correct |
25 |
Correct |
1 ms |
2092 KB |
Output is correct |
26 |
Incorrect |
14 ms |
3800 KB |
1st lines differ - on the 1st token, expected: '21261825233649', found: '774766749' |
27 |
Halted |
0 ms |
0 KB |
- |