# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
747819 | 2023-05-24T20:33:11 Z | b00norp | Catfish Farm (IOI22_fish) | C++17 | 152 ms | 29756 KB |
#include "fish.h" #include <bits/stdc++.h> #include <vector> using namespace std; bool cmp(array<long long, 3> a, array<long long, 3> b) { if(a[1] == b[1]) { return a[0] > b[0]; } return a[1] < b[1]; } long long max_weights(int n, int m, vector<int> x, vector<int> y, vector<int> w) { long long N = n, M = m; vector<long long> X, Y, W; for(long long i = 0; i < M; i++) { X.push_back(x[i]); Y.push_back(y[i]); W.push_back(w[i]); } if(N == 2) { vector<long long> ans(2, 0); for(long long i = 0; i < M; i++) { ans[X[i]] += W[i]; } return max(ans[0], ans[1]); } vector<array<long long, 3> > fishes; for(long long i = 0; i < M; i++) { fishes.push_back({X[i], Y[i], W[i]}); } sort(fishes.begin(), fishes.end(), cmp); long long ans = 0, cur_ans = 0; for(long long i = 0; i < fishes.size(); i++) { if(fishes[i][0] == 1) { cur_ans += fishes[i][2]; } } ans = cur_ans; for(long long i = 0; i < fishes.size(); i++) { if(fishes[i][0] == 1) { cur_ans -= fishes[i][2]; } else { cur_ans += fishes[i][2]; } ans = max(ans, cur_ans); } return ans; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 35 ms | 7856 KB | Output is correct |
2 | Correct | 44 ms | 8744 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 147 ms | 29756 KB | Output is correct |
6 | Correct | 152 ms | 29740 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 76 ms | 15600 KB | Output is correct |
3 | Correct | 96 ms | 20820 KB | Output is correct |
4 | Correct | 41 ms | 9268 KB | Output is correct |
5 | Correct | 46 ms | 10576 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 304 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 0 ms | 212 KB | Output is correct |
10 | Correct | 0 ms | 212 KB | Output is correct |
11 | Correct | 1 ms | 212 KB | Output is correct |
12 | Correct | 39 ms | 9284 KB | Output is correct |
13 | Correct | 46 ms | 10524 KB | Output is correct |
14 | Correct | 38 ms | 9284 KB | Output is correct |
15 | Correct | 44 ms | 9904 KB | Output is correct |
16 | Correct | 41 ms | 9284 KB | Output is correct |
17 | Correct | 43 ms | 9896 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Incorrect | 23 ms | 4764 KB | 1st lines differ - on the 1st token, expected: '21261825233649', found: '26722445760742' |
4 | 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 | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Incorrect | 23 ms | 4764 KB | 1st lines differ - on the 1st token, expected: '21261825233649', found: '26722445760742' |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 35 ms | 7856 KB | Output is correct |
2 | Correct | 44 ms | 8744 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 147 ms | 29756 KB | Output is correct |
6 | Correct | 152 ms | 29740 KB | Output is correct |
7 | Correct | 0 ms | 212 KB | Output is correct |
8 | Correct | 76 ms | 15600 KB | Output is correct |
9 | Correct | 96 ms | 20820 KB | Output is correct |
10 | Correct | 41 ms | 9268 KB | Output is correct |
11 | Correct | 46 ms | 10576 KB | Output is correct |
12 | Correct | 0 ms | 212 KB | Output is correct |
13 | Correct | 0 ms | 304 KB | Output is correct |
14 | Correct | 1 ms | 212 KB | Output is correct |
15 | Correct | 0 ms | 212 KB | Output is correct |
16 | Correct | 0 ms | 212 KB | Output is correct |
17 | Correct | 1 ms | 212 KB | Output is correct |
18 | Correct | 39 ms | 9284 KB | Output is correct |
19 | Correct | 46 ms | 10524 KB | Output is correct |
20 | Correct | 38 ms | 9284 KB | Output is correct |
21 | Correct | 44 ms | 9904 KB | Output is correct |
22 | Correct | 41 ms | 9284 KB | Output is correct |
23 | Correct | 43 ms | 9896 KB | Output is correct |
24 | Correct | 0 ms | 212 KB | Output is correct |
25 | Correct | 0 ms | 212 KB | Output is correct |
26 | Incorrect | 23 ms | 4764 KB | 1st lines differ - on the 1st token, expected: '21261825233649', found: '26722445760742' |
27 | Halted | 0 ms | 0 KB | - |