#include "fish.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
typedef vector<vpi> vvpi;
typedef vector<vpll> vvpll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef short int si;
typedef vector<si> vsi;
typedef vector<vsi> vvsi;
#define IOS ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define L(varll, mn, mx) for(ll varll = (mn); varll < (mx); varll++)
#define LR(varll, mx, mn) for(ll varll = (mx); varll > (mn); varll--)
#define LI(vari, mn, mx) for(int vari = (mn); vari < (mx); vari++)
#define LIR(vari, mx, mn) for(int vari = (mx); vari > (mn); vari--)
#define INPV(varvec) for(auto& varveci : (varvec)) cin >> varveci
#define fi first
#define se second
#define pb push_back
#define INF(type) numeric_limits<type>::max()
#define NINF(type) numeric_limits<type>::min()
#define TCASES int t; cin >> t; while(t--)
ll max_weights(int N, int M, vi X, vi Y, vi W) {
vvll g;
L(i, 0ll, 2ll) {
vll gr(N, 0ll);
g.pb(gr);
}
L(i, 0ll, M) {
g[X[i]][Y[i]] = W[i];
}
ll ans = 0ll;
ll sum0 = 0ll;
ll sum1 = 0ll;
for(ll i = 0ll; i < M; i++) {
(X[i] == 0 ? sum0 : sum1) += (ll)W[i];
}
if(N == 2) {
ans = max(sum0, sum1);
} else {
vll pref_0(N + 1ll, 0ll);
vll suff_1(N + 1ll, 0ll);
L(i, 0ll, N) {
pref_0[i + 1ll] = pref_0[i] + g[0ll][i];
}
LR(i, N - 1ll, -1ll) {
suff_1[i] = suff_1[i + 1ll] + g[1ll][i];
}
L(i, 0ll, N + 1ll) {
ans = max(ans, pref_0[i] + suff_1[i]);
}
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
18 ms |
5016 KB |
Output is correct |
2 |
Correct |
15 ms |
5708 KB |
Output is correct |
3 |
Correct |
2 ms |
3404 KB |
Output is correct |
4 |
Correct |
1 ms |
3404 KB |
Output is correct |
5 |
Runtime error |
66 ms |
19552 KB |
Execution killed with signal 11 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
25 ms |
7068 KB |
Output is correct |
3 |
Correct |
56 ms |
11592 KB |
Output is correct |
4 |
Correct |
13 ms |
6432 KB |
Output is correct |
5 |
Correct |
16 ms |
7492 KB |
Output is correct |
6 |
Correct |
0 ms |
344 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 |
1 ms |
3404 KB |
Output is correct |
11 |
Correct |
2 ms |
3404 KB |
Output is correct |
12 |
Correct |
13 ms |
6440 KB |
Output is correct |
13 |
Correct |
17 ms |
7496 KB |
Output is correct |
14 |
Correct |
14 ms |
6448 KB |
Output is correct |
15 |
Correct |
25 ms |
7236 KB |
Output is correct |
16 |
Correct |
14 ms |
6448 KB |
Output is correct |
17 |
Correct |
23 ms |
7096 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
3404 KB |
Output is correct |
2 |
Runtime error |
2 ms |
5196 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
348 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
348 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
348 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
3404 KB |
Output is correct |
2 |
Runtime error |
2 ms |
5196 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
18 ms |
5016 KB |
Output is correct |
2 |
Correct |
15 ms |
5708 KB |
Output is correct |
3 |
Correct |
2 ms |
3404 KB |
Output is correct |
4 |
Correct |
1 ms |
3404 KB |
Output is correct |
5 |
Runtime error |
66 ms |
19552 KB |
Execution killed with signal 11 |
6 |
Halted |
0 ms |
0 KB |
- |