Submission #1061410

#TimeUsernameProblemLanguageResultExecution timeMemory
1061410MarwenElarbiCatfish Farm (IOI22_fish)C++17
6 / 100
93 ms14692 KiB
#include <bits/stdc++.h> #include "fish.h" using namespace std; #define pb push_back #define ll long long #define fi first #define se second long long max_weights(int N, int M, std::vector<int> X, std::vector<int> Y, std::vector<int> W) { int n=N; long long a=0; long long b=0; vector<pair<int,int>> tab[2]; for (int i = 0; i < W.size(); ++i) { tab[X[i]].pb({Y[i],W[i]}); (X[i] == 0 ? a : b) += W[i]; } if(N==2) return max(a,b); sort(tab[0].begin(),tab[0].end()); sort(tab[1].begin(),tab[1].end()); long long pre[n]; long long suf[n]; int j=0; for (int i = 0; i < n; ++i) { pre[i]=0; if(j<tab[0].size()&&tab[0][j].fi==i){ pre[i]=tab[0][j++].se; } if(i) pre[i]+=pre[i-1]; } j=tab[1].size()-1; for (int i = n-1; i >= 0; --i) { suf[i]=0; if(j>=0&&tab[1][j].fi==i){ suf[i]=tab[1][j--].se; } if(i<n-1) suf[i]+=suf[i+1]; } long long ans=suf[0]; for (int i = 0; i < n-1; ++i) { ans=max(ans,suf[i+1]+pre[i]); } ans=max(ans,pre[n-1]); 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:14:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |   for (int i = 0; i < W.size(); ++i)
      |                   ~~^~~~~~~~~~
fish.cpp:28:9: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |     if(j<tab[0].size()&&tab[0][j].fi==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...