Submission #827880

#TimeUsernameProblemLanguageResultExecution timeMemory
827880SebCatfish Farm (IOI22_fish)C++17
9 / 100
108 ms15580 KiB
#include "fish.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; #define f first #define s second long long max_weights(int N, int M, std::vector<int> X, std::vector<int> Y,std::vector<int> W) { if (N==2) { ll a=0,b=0; for (int i=0;i<M;i++) { if (X[i]==0) a += W[i]; else b += W[i]; } return max(a,b); } else { ll ans = 0,a=0,b=0,p0=0,p1=0; vector <pair<ll,ll>> cero,uno; for (int i=0;i<M;i++) { if (X[i]==1) { b += W[i]; uno.push_back({Y[i],W[i]}); } else cero.push_back({Y[i],W[i]}); } sort(cero.begin(),cero.end()); sort(uno.begin(),uno.end()); for (p0=0;p0<cero.size();p0++) { ans = max(ans,a+b); a += cero[p0].s; while (p1<uno.size() && uno[p1].f <= cero[p0].f) { b -= uno[p1].s; p1++; } } ans = max(ans,a+b); 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:31:17: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |     for (p0=0;p0<cero.size();p0++) {
      |               ~~^~~~~~~~~~~~
fish.cpp:34:18: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |         while (p1<uno.size() && uno[p1].f <= cero[p0].f) {
      |                ~~^~~~~~~~~~~
#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...