#include "fish.h"
#include <bits/stdc++.h>
using namespace std;
#define ll int
#define sz(x) (ll)x.size()
#define F first
#define S second
#define endl "\n"
#define pb push_back
typedef vector <ll> vi;
typedef vector <long long> vl;
typedef pair <ll,ll> ii;
typedef vector <ii> vii;
#define dbg(x) cout<<#x<<": "<<x<<endl;
#define dbg2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl;
#define dbg3(x,y,z) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<" "<<#z<<": "<<z<<endl;
void printVct(vi &v){
for(ll i =0; i<sz(v); i++){
cout<<v[i]<<" ";
}
cout<<endl;
}
long long getSum(ll l, ll r, const vl &s){
if (l == 0) return s[r];
return s[r] - s[l-1];
}
long long max_weights(int N, int M, vi X, vi Y, vi w){
ll n = N, m = M;
vl s0(n), s1(n);
for (ll i = 0; i<m; i++){
ll x = X[i], y = Y[i];
if (x == 0){
s0[y] = w[i];
}
else{
s1[y] = w[i];
}
}
for (ll i = 1; i<n; i++){
s0[i] += s0[i-1];
s1[i] += s1[i-1];
}
long long ans = 0;
if (n >= 3){
//can only build at x = 1
long long preAns = s1.back();
for (ll i =0; i<n; i++){
long long cur = getSum(0,i,s0) + preAns - getSum(0,i,s1);
ans = max(ans, cur);
}
}
else{
for (ll i =0; i<n; i++){
long long cur0 = getSum(0,i,s1), cur1 = getSum(0, i, s0);
ans = max(ans, max(cur1, cur0));
}
}
return ans;
}
/*
6 4
0 2 5
2 1 4
4 4 1
6 3 3
6 6
0 2 5
1 1 4
0 4 1
0 3 3
1 2 4
1 6 2
5 4
0 2 5
1 1 2
4 4 1
3 3 3
*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
19 ms |
4956 KB |
Output is correct |
2 |
Correct |
24 ms |
5980 KB |
Output is correct |
3 |
Correct |
2 ms |
1884 KB |
Output is correct |
4 |
Correct |
1 ms |
1976 KB |
Output is correct |
5 |
Incorrect |
71 ms |
15188 KB |
1st lines differ - on the 1st token, expected: '149814460735479', found: '49851878555251' |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
38 ms |
8276 KB |
Output is correct |
3 |
Correct |
46 ms |
10068 KB |
Output is correct |
4 |
Correct |
20 ms |
4952 KB |
Output is correct |
5 |
Correct |
23 ms |
6120 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 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
1880 KB |
Output is correct |
11 |
Correct |
2 ms |
1884 KB |
Output is correct |
12 |
Correct |
19 ms |
5100 KB |
Output is correct |
13 |
Incorrect |
23 ms |
5980 KB |
1st lines differ - on the 1st token, expected: '49960364197170', found: '49959843224072' |
14 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
1880 KB |
Output is correct |
2 |
Incorrect |
1 ms |
1884 KB |
1st lines differ - on the 1st token, expected: '882019', found: '0' |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 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 |
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 |
Incorrect |
0 ms |
348 KB |
1st lines differ - on the 1st token, expected: '2', found: '1' |
9 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 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 |
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 |
Incorrect |
0 ms |
348 KB |
1st lines differ - on the 1st token, expected: '2', found: '1' |
9 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 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 |
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 |
Incorrect |
0 ms |
348 KB |
1st lines differ - on the 1st token, expected: '2', found: '1' |
9 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
1880 KB |
Output is correct |
2 |
Incorrect |
1 ms |
1884 KB |
1st lines differ - on the 1st token, expected: '882019', found: '0' |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
19 ms |
4956 KB |
Output is correct |
2 |
Correct |
24 ms |
5980 KB |
Output is correct |
3 |
Correct |
2 ms |
1884 KB |
Output is correct |
4 |
Correct |
1 ms |
1976 KB |
Output is correct |
5 |
Incorrect |
71 ms |
15188 KB |
1st lines differ - on the 1st token, expected: '149814460735479', found: '49851878555251' |
6 |
Halted |
0 ms |
0 KB |
- |