#include <bits/stdc++.h>
using namespace std;
#define ll long long
constexpr int MAXN = 1e5 + 5;
ll sum_tutto(int N, int M, vector<int> X, vector<int> Y, vector<int> W) {
ll sum = 0;
for (auto x : W) sum += x;
return sum;
}
ll res_minore_di_due(int N, int M, vector<int> X, vector<int> Y, vector<int> W) {
if (N == 2) exit(-1);
ll sum = 0;
for (int i = 0; i < M; i ++) {
if (X[i] == 1) sum += W[i];
}
// cout << "sum : " << sum << '\n';
vector<vector<ll>> pos(2, vector<ll>(N + 5, 0));
for (int i = 0; i < M; i ++) {
pos[X[i]][Y[i]] += W[i];
}
// for (int i = 0; i < N + 5; i ++) {
// cout << pos[0][i] << " ";
// }
// cout << '\n';
// for (int i = 0; i < N + 5; i ++) {
// cout << pos[1][i] << " ";
// }
// cout << '\n';
ll best_res = sum;
ll sum_zero = 0;
ll sum_uno = 0;
for (int i = 0; i < N + 5; i ++) {
sum_zero += pos[0][i];
sum_uno += pos[1][i];
best_res = max(best_res, sum - sum_uno + sum_zero);
// cout << "per i : " << i << " avremmo " << sum - sum_uno + sum_zero << '\n';
}
return best_res;
}
ll max_weights(int N, int M, vector<int> X, vector<int> Y, vector<int> W) {
bool all_even = 1;
for (auto x : X) if (x % 2) all_even = 0;
if (all_even) return sum_tutto(N, M, X, Y, W);
bool minore_di_due = 1;
for (auto x : X) if (x >= 2) minore_di_due = 0;
return res_minore_di_due(N, M, X, Y, W);
}
Compilation message
fish.cpp: In function 'long long int max_weights(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
fish.cpp:56:10: warning: variable 'minore_di_due' set but not used [-Wunused-but-set-variable]
56 | bool minore_di_due = 1;
| ^~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
15 ms |
4440 KB |
Output is correct |
2 |
Correct |
20 ms |
5724 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
66 ms |
17128 KB |
Output is correct |
6 |
Correct |
63 ms |
17488 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
35 ms |
10896 KB |
Output is correct |
3 |
Correct |
38 ms |
13220 KB |
Output is correct |
4 |
Correct |
15 ms |
4440 KB |
Output is correct |
5 |
Correct |
17 ms |
5468 KB |
Output is correct |
6 |
Runtime error |
1 ms |
348 KB |
Execution failed because the return code was nonzero |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Runtime error |
2 ms |
3660 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
604 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
604 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
604 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Runtime error |
2 ms |
3660 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
15 ms |
4440 KB |
Output is correct |
2 |
Correct |
20 ms |
5724 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
66 ms |
17128 KB |
Output is correct |
6 |
Correct |
63 ms |
17488 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
35 ms |
10896 KB |
Output is correct |
9 |
Correct |
38 ms |
13220 KB |
Output is correct |
10 |
Correct |
15 ms |
4440 KB |
Output is correct |
11 |
Correct |
17 ms |
5468 KB |
Output is correct |
12 |
Runtime error |
1 ms |
348 KB |
Execution failed because the return code was nonzero |
13 |
Halted |
0 ms |
0 KB |
- |