Submission #625983

# Submission time Handle Problem Language Result Execution time Memory
625983 2022-08-11T05:46:26 Z sword060 Catfish Farm (IOI22_fish) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include "fish.h"
using namespace std;
long long max_weights(int x,int k,vector<int> a,vector<int> b,vector<int> c){
  vector<pair<int,int>>l[2];
  long long ans=0,cur=0;
  for(int i=0;i<k;i++){
    l[1-(a[i]%2)].push_back({y,c[i]});
    if(1-(a[i]%2))cur+=c[i];
  }
  sort(l[0].begin(),l[0].end());
  sort(l[1].begin(),l[1].end());
  ans=cur;
  int j=(int)l[0].size()-1;
  for(int i=(int)l[1].size()-1;i>=0;i--){
    cur+=l[1][i].second;
    while(j>=0&&l[0][j].first>=l[1][i].first){
      cur-=l[1][i].second;
      j--;
    }
    ans=max(ans,cur);
  }
  return ans;
}

Compilation message

fish.cpp: In function 'long long int max_weights(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
fish.cpp:8:30: error: 'y' was not declared in this scope
    8 |     l[1-(a[i]%2)].push_back({y,c[i]});
      |                              ^
fish.cpp:8:37: error: no matching function for call to 'std::vector<std::pair<int, int> >::push_back(<brace-enclosed initializer list>)'
    8 |     l[1-(a[i]%2)].push_back({y,c[i]});
      |                                     ^
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/functional:62,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from fish.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:1187:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::value_type = std::pair<int, int>]'
 1187 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1187:35: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const std::pair<int, int>&'}
 1187 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:1203:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::value_type = std::pair<int, int>]'
 1203 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1203:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<std::pair<int, int> >::value_type&&' {aka 'std::pair<int, int>&&'}
 1203 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~