#include "fish.h"
#include<bits/stdc++.h>
#include<iostream>
#include<math.h>
#include <vector>
using namespace std;
long long max_weights(int n, int m, std::vector<int> x, std::vector<int> y,std::vector<int> w) {
int mx1 = -1, mx2 = -1;
vector<vector<long long>> grid(n, vector<long long>(2,0LL));
for (int i = 0; i < m; i++) {
if (x[i] == 0) mx1 = max(mx1, y[i]);
else mx2 = max(mx2, y[i]);
grid[y[i]][x[i]] = w[i];
}
if (mx1 == -1 || mx2 == -1) {
return accumulate(w.begin(), w.end(),0LL);
}
else {
long long ans = 0;
for (int i = min(mx1, mx2) + 1; i <= max(mx1, mx2) && i<=n-1; i++) {
ans += grid[i][0] + grid[i][1];
}
long long meow0 = 0,meow1 = 0;
for (int i = min(mx1, mx2); i >= 0;i--) {
meow0 += grid[i][0];
meow1 += grid[i][1];
}
return ans + max(meow0,meow1);
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
31 ms |
7116 KB |
Output is correct |
2 |
Correct |
37 ms |
8120 KB |
Output is correct |
3 |
Correct |
7 ms |
5776 KB |
Output is correct |
4 |
Correct |
7 ms |
5716 KB |
Output is correct |
5 |
Runtime error |
93 ms |
25716 KB |
Execution killed with signal 11 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
55 ms |
8996 KB |
1st lines differ - on the 1st token, expected: '40604614618209', found: '40479197388443' |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
5776 KB |
Output is correct |
2 |
Runtime error |
12 ms |
11544 KB |
Execution killed with signal 6 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
1st lines differ - on the 1st token, expected: '3', found: '2' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
1st lines differ - on the 1st token, expected: '3', found: '2' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
1st lines differ - on the 1st token, expected: '3', found: '2' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
5776 KB |
Output is correct |
2 |
Runtime error |
12 ms |
11544 KB |
Execution killed with signal 6 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
31 ms |
7116 KB |
Output is correct |
2 |
Correct |
37 ms |
8120 KB |
Output is correct |
3 |
Correct |
7 ms |
5776 KB |
Output is correct |
4 |
Correct |
7 ms |
5716 KB |
Output is correct |
5 |
Runtime error |
93 ms |
25716 KB |
Execution killed with signal 11 |
6 |
Halted |
0 ms |
0 KB |
- |