Submission #747819

#TimeUsernameProblemLanguageResultExecution timeMemory
747819b00norpCatfish Farm (IOI22_fish)C++17
9 / 100
152 ms29756 KiB
#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 (stderr)

fish.cpp: In function 'long long int max_weights(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
fish.cpp:42:28: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::array<long long int, 3> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |     for(long long i = 0; i < fishes.size(); i++)
      |                          ~~^~~~~~~~~~~~~~~
fish.cpp:50:28: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::array<long long int, 3> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |     for(long long i = 0; i < fishes.size(); i++)
      |                          ~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...