#include <bits/stdc++.h>
#define endl "\n"
#define finp for(int i=0; i<n; i++)
#define fknp for(int k=0; k<n; k++)
#define yeap cout<<"YES"<<endl
#define nope cout<<"NO"<<endl
#define inpintn int n; cin>>n
#define inpintarrn int arr[n]; for(int i=0; i<n; i++){cin>>arr[i];}
#define inpllarrn long long arr[n]; for(int i=0; i<n; i++){cin>>arr[i];}
#define ll long long
using namespace std;
#include "fish.h"
#include <vector>
long long max_weights(int N, int M, std::vector<int> X, std::vector<int> Y,
std::vector<int> W) {
ll vis0[N];
ll vis1[N];
ll sum0 = 0;
ll sum1 = 0;
vector<ll> v0[N];
vector<ll> v1[N];
for(int i=0; i<N; i++){
vis0[i] = 0;
vis1[i] = 0;
}
for(int i=0; i<M; i++){
ll a = Y[i];
ll b = W[i];
if(X[i]==0){
vis0[a] = 1;
sum0 = sum0+b;
v0[a].push_back(b);
} else {
vis1[a] = 1;
sum1 = sum1+b;
v1[a].push_back(b);
}
}
if(N==2){
ll ans = max(sum0, sum1);
return ans;
} else {
ll ans = sum1;
ll l = 0;
ll r = sum1;
for(int i=0; i<N; i++){
if(i<N-1){
if(vis0[i]==1){
ll c = v0[i][0];
l = l+c;
}
if(vis1[i]==1){
ll c = v1[i][0];
r = r-c;
}
ll temp = l+r;
ans = max(temp, ans);
} else {
ll temp = sum0;
ans = max(temp, ans);
}
}
return ans;
}
// ll ans = sum1;
// ll l = 0;
// ll r = sum1;
// for(int i=0; i<N; i++){
// if(i<N-1){
// if(vis0[i]==1){
// ll c = v0[i][0];
// l = l+c;
// }
// if(vis1[i]==1){
// ll c = v1[i][0];
// r = r-c;
// }
// ll temp = l+r;
// ans = max(temp, ans);
// } else {
// ll temp = sum0;
// ans = max(temp, ans);
// }
// }
// return ans;
// return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
26 ms |
11868 KB |
Output is correct |
2 |
Correct |
33 ms |
13652 KB |
Output is correct |
3 |
Correct |
4 ms |
6488 KB |
Output is correct |
4 |
Correct |
4 ms |
6492 KB |
Output is correct |
5 |
Correct |
88 ms |
24912 KB |
Output is correct |
6 |
Incorrect |
88 ms |
25176 KB |
1st lines differ - on the 1st token, expected: '300000000000000', found: '299997000000000' |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
51 ms |
17568 KB |
Output is correct |
3 |
Correct |
65 ms |
21076 KB |
Output is correct |
4 |
Correct |
26 ms |
11868 KB |
Output is correct |
5 |
Correct |
33 ms |
13916 KB |
Output is correct |
6 |
Correct |
0 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 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
4 ms |
6492 KB |
Output is correct |
11 |
Correct |
4 ms |
6576 KB |
Output is correct |
12 |
Correct |
26 ms |
11860 KB |
Output is correct |
13 |
Correct |
33 ms |
13904 KB |
Output is correct |
14 |
Correct |
27 ms |
11876 KB |
Output is correct |
15 |
Correct |
32 ms |
13140 KB |
Output is correct |
16 |
Correct |
26 ms |
11868 KB |
Output is correct |
17 |
Correct |
30 ms |
13136 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
6492 KB |
Output is correct |
2 |
Correct |
4 ms |
6492 KB |
Output is correct |
3 |
Incorrect |
17 ms |
9176 KB |
1st lines differ - on the 1st token, expected: '21261825233649', found: '26722445760742' |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 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 |
Incorrect |
0 ms |
348 KB |
1st lines differ - on the 1st token, expected: '216624184325', found: '310613614938' |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 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 |
Incorrect |
0 ms |
348 KB |
1st lines differ - on the 1st token, expected: '216624184325', found: '310613614938' |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 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 |
Incorrect |
0 ms |
348 KB |
1st lines differ - on the 1st token, expected: '216624184325', found: '310613614938' |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
6492 KB |
Output is correct |
2 |
Correct |
4 ms |
6492 KB |
Output is correct |
3 |
Incorrect |
17 ms |
9176 KB |
1st lines differ - on the 1st token, expected: '21261825233649', found: '26722445760742' |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
26 ms |
11868 KB |
Output is correct |
2 |
Correct |
33 ms |
13652 KB |
Output is correct |
3 |
Correct |
4 ms |
6488 KB |
Output is correct |
4 |
Correct |
4 ms |
6492 KB |
Output is correct |
5 |
Correct |
88 ms |
24912 KB |
Output is correct |
6 |
Incorrect |
88 ms |
25176 KB |
1st lines differ - on the 1st token, expected: '300000000000000', found: '299997000000000' |
7 |
Halted |
0 ms |
0 KB |
- |