Submission #720541

#TimeUsernameProblemLanguageResultExecution timeMemory
720541lamCatfish Farm (IOI22_fish)C++17
6 / 100
92 ms14316 KiB
#include "fish.h" #include <vector> #define ll long long #include <bits/stdc++.h> using namespace std; typedef pair<int,int> ii; #define ff first #define ss second const int maxn = 3e5 + 10; int n,m; ii a[maxn]; int w[maxn]; bool cmp(int x, int y) { return a[x]<a[y]; } ll sub2(vector <int> X, vector <int> Y, vector <int> W) { ll ans=0; ll sum=0; vector <int> id[2]; for (int i=0; i<m; i++) if (X[i]==0) sum+=W[i], id[0].push_back(i); ans=sum; sum=0; for (int i=0; i<m; i++) if (X[i]==1) sum+=W[i], id[1].push_back(i); ans=max(ans,sum); if (n==2) return ans; sort(id[0].begin(),id[0].end(),cmp); sort(id[1].begin(),id[1].end(),cmp); int it[2]; it[0]=it[1]=0; for (int y=0; y<n; y++) { while (it[0]<id[0].size()&&a[id[0][it[0]]].ss <= y) sum+=w[id[0][it[0]++]]; while (it[1]<id[1].size()&&a[id[1][it[1]]].ss <= y) sum-=w[id[1][it[1]++]]; // cerr<<y<<" : "<<sum<<'\n'; ans=max(ans,sum); } return ans; } long long max_weights(int N, int M, std::vector<int> X, std::vector<int> Y, std::vector<int> W) { n=N; m=M; for (int i=0; i<m; i++) a[i]={X[i],Y[i]}, w[i]=W[i]; return sub2(X,Y,W); }

Compilation message (stderr)

fish.cpp: In function 'long long int sub2(std::vector<int>, std::vector<int>, std::vector<int>)':
fish.cpp:37:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |         while (it[0]<id[0].size()&&a[id[0][it[0]]].ss <= y) sum+=w[id[0][it[0]++]];
      |                ~~~~~^~~~~~~~~~~~~
fish.cpp:38:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |         while (it[1]<id[1].size()&&a[id[1][it[1]]].ss <= y) sum-=w[id[1][it[1]++]];
      |                ~~~~~^~~~~~~~~~~~~
#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...