#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<int>> grid(n, vector<int>(2,0));
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 |
28 ms |
7116 KB |
Output is correct |
2 |
Correct |
37 ms |
8132 KB |
Output is correct |
3 |
Correct |
6 ms |
5716 KB |
Output is correct |
4 |
Correct |
6 ms |
5716 KB |
Output is correct |
5 |
Runtime error |
94 ms |
25692 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 |
52 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 |
6 ms |
5716 KB |
Output is correct |
2 |
Runtime error |
10 ms |
11468 KB |
Execution killed with signal 6 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 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 |
0 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 |
0 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 |
6 ms |
5716 KB |
Output is correct |
2 |
Runtime error |
10 ms |
11468 KB |
Execution killed with signal 6 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
28 ms |
7116 KB |
Output is correct |
2 |
Correct |
37 ms |
8132 KB |
Output is correct |
3 |
Correct |
6 ms |
5716 KB |
Output is correct |
4 |
Correct |
6 ms |
5716 KB |
Output is correct |
5 |
Runtime error |
94 ms |
25692 KB |
Execution killed with signal 11 |
6 |
Halted |
0 ms |
0 KB |
- |