#include <iostream>
#include <vector>
#define ll long long
using namespace std;
ll max_weights(int n, int m, vector<int> x, vector<int> y, vector<int> w) {
ll res;
if(n == 2) {
ll r0 = 0, r1 = 0;
for(ll i = 0; i < m; i++) {
if(x[i]) r1+=w[i];
else r0+=w[i];
}
res = max(r0, r1);
} else {
vector<ll> pref0(n), pref1(n);
for(int i = 0; i < m; i++) {
if(x[i]) pref1[y[i]] = w[i];
else pref0[y[i]] = w[i];
}
for(int i = 1; i < n; i++) {
pref0[i]+=pref0[i-1];
pref1[i]+=pref1[i-1];
}
res = pref1[n-1];
for(int i = 0; i < n; i++) res = max(res, pref0[i]+pref1[n-1]-pref1[i]);
}
return res;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
24 ms |
3540 KB |
Output is correct |
2 |
Correct |
22 ms |
4180 KB |
Output is correct |
3 |
Correct |
1 ms |
1748 KB |
Output is correct |
4 |
Correct |
1 ms |
1748 KB |
Output is correct |
5 |
Incorrect |
68 ms |
8800 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 |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
36 ms |
5416 KB |
Output is correct |
3 |
Correct |
46 ms |
9936 KB |
Output is correct |
4 |
Correct |
19 ms |
4940 KB |
Output is correct |
5 |
Correct |
24 ms |
5984 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
2 ms |
1876 KB |
Output is correct |
11 |
Correct |
2 ms |
1876 KB |
Output is correct |
12 |
Correct |
18 ms |
4948 KB |
Output is correct |
13 |
Correct |
22 ms |
5836 KB |
Output is correct |
14 |
Correct |
19 ms |
4940 KB |
Output is correct |
15 |
Correct |
24 ms |
5452 KB |
Output is correct |
16 |
Correct |
19 ms |
4948 KB |
Output is correct |
17 |
Correct |
21 ms |
5452 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1876 KB |
Output is correct |
2 |
Correct |
1 ms |
1876 KB |
Output is correct |
3 |
Incorrect |
13 ms |
2900 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 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Incorrect |
1 ms |
212 KB |
1st lines differ - on the 1st token, expected: '216624184325', found: '2268305442' |
10 |
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 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Incorrect |
1 ms |
212 KB |
1st lines differ - on the 1st token, expected: '216624184325', found: '2268305442' |
10 |
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 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Incorrect |
1 ms |
212 KB |
1st lines differ - on the 1st token, expected: '216624184325', found: '2268305442' |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1876 KB |
Output is correct |
2 |
Correct |
1 ms |
1876 KB |
Output is correct |
3 |
Incorrect |
13 ms |
2900 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 |
24 ms |
3540 KB |
Output is correct |
2 |
Correct |
22 ms |
4180 KB |
Output is correct |
3 |
Correct |
1 ms |
1748 KB |
Output is correct |
4 |
Correct |
1 ms |
1748 KB |
Output is correct |
5 |
Incorrect |
68 ms |
8800 KB |
1st lines differ - on the 1st token, expected: '149814460735479', found: '49851995244248' |
6 |
Halted |
0 ms |
0 KB |
- |