Submission #237040

#TimeUsernameProblemLanguageResultExecution timeMemory
237040crossing0ver휴가 (IOI14_holiday)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> #include"holiday.h" #define ll long long #define fi first #define se second using namespace std; int n,x,d,val[100005]; ll solveR() { set <pair<int,int> > s; ll eaten = 0,ans = val[x]; int left = 0; eaten = val[x]; s.insert({val[x],x}); for (int i = x + 1; i < n; i++) { int stamina = i + s.size(); if (i >= d) {left = i + 1; break;} while (stamina >= d) { eaten -= (*s.begin()).fi; s.erase(s.begin()); stamina--; } if (stamina < d) { eaten += val[i]; s.insert({val[i],i}); } ans = max(ans,eaten); } return ans; } ll solve() { set <pair<int,int> > s; ll eaten = 0,ans = val[x]; int left = 0; for (int i = x; i >= 0; i--) { s.insert({val[i],i}); eaten += val[i]; } int l = 0; for (int i = x + 1; i < n && i < x + d; i++) { int stamina = i - x + i - l + s.size(); while (stamina >= d) { if (i - x + i - l >= d) { stamina--; if (s.find({val[l],l}) != s.end()) { stamina--; s.erase({val[l],l}); eaten -= val[l]; } l++; } else { if (s.find({val[l],l}) == s.end()) { l++; stamina--; continue; } int in = (*s.begin()).se; eaten -= (*s.begin()).fi; if (in == l) { l++; // if ( l != x) stamina-=2; else stamina--; } else stamina--; s.erase(s.begin()); } } s.insert({val[i],i}); eaten += val[i]; ans = max(ans,eaten); } return ans; } long long int findMaxAttraction(int n1, int start, int d1, int attraction[]) { n = n1; x = start; d = d1; ll ans = 0; if (!d) return 0; if (d == 1) return val[start]; for (int i = 0; i < n; i ++) val[i] = attraction[i]; ans = max(ans,solveR()); ans = max(ans,solve()); for (int i = 0 ;i < n; i++) val[i] = attraction[n-i]; x = n - x; ans = max(ans,solveR()); ans = max(ans,solve()); return ans; } /* main(){ int n,start,d; cin >> n >> start >> d; int att[n]; for (int i = 0; i < n ;i ++) cin >> att[i]; cout << findMaxAttraction(n,start,d,att); } */

Compilation message (stderr)

holiday.cpp: In function 'long long int solveR()':
holiday.cpp:11:6: warning: variable 'left' set but not used [-Wunused-but-set-variable]
  int left = 0;
      ^~~~
holiday.cpp: In function 'long long int solve()':
holiday.cpp:63:6: error: expected '}' before 'else'
      else stamina--;
      ^~~~
holiday.cpp:65:5: error: 'else' without a previous 'if'
     else  stamina--;
     ^~~~
holiday.cpp:69:18: error: 'i' was not declared in this scope
    s.insert({val[i],i});
                  ^
holiday.cpp:69:23: error: no matching function for call to 'std::set<std::pair<int, int> >::insert(<brace-enclosed initializer list>)'
    s.insert({val[i],i});
                       ^
In file included from /usr/include/c++/7/set:61:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:87,
                 from holiday.cpp:1:
/usr/include/c++/7/bits/stl_set.h:499:7: note: candidate: std::pair<typename std::_Rb_tree<_Key, _Key, std::_Identity<_Key>, _Compare, typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other>::const_iterator, bool> std::set<_Key, _Compare, _Alloc>::insert(const value_type&) [with _Key = std::pair<int, int>; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<int, int> >; typename std::_Rb_tree<_Key, _Key, std::_Identity<_Key>, _Compare, typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other>::const_iterator = std::_Rb_tree_const_iterator<std::pair<int, int> >; std::set<_Key, _Compare, _Alloc>::value_type = std::pair<int, int>]
       insert(const value_type& __x)
       ^~~~~~
/usr/include/c++/7/bits/stl_set.h:499:7: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type& {aka const std::pair<int, int>&}'
/usr/include/c++/7/bits/stl_set.h:508:7: note: candidate: std::pair<typename std::_Rb_tree<_Key, _Key, std::_Identity<_Key>, _Compare, typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other>::const_iterator, bool> std::set<_Key, _Compare, _Alloc>::insert(std::set<_Key, _Compare, _Alloc>::value_type&&) [with _Key = std::pair<int, int>; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<int, int> >; typename std::_Rb_tree<_Key, _Key, std::_Identity<_Key>, _Compare, typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other>::const_iterator = std::_Rb_tree_const_iterator<std::pair<int, int> >; std::set<_Key, _Compare, _Alloc>::value_type = std::pair<int, int>]
       insert(value_type&& __x)
       ^~~~~~
/usr/include/c++/7/bits/stl_set.h:508:7: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::set<std::pair<int, int> >::value_type&& {aka std::pair<int, int>&&}'
/usr/include/c++/7/bits/stl_set.h:536:7: note: candidate: std::set<_Key, _Compare, _Alloc>::iterator std::set<_Key, _Compare, _Alloc>::insert(std::set<_Key, _Compare, _Alloc>::const_iterator, const value_type&) [with _Key = std::pair<int, int>; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<int, int> >; std::set<_Key, _Compare, _Alloc>::iterator = std::_Rb_tree_const_iterator<std::pair<int, int> >; std::set<_Key, _Compare, _Alloc>::const_iterator = std::_Rb_tree_const_iterator<std::pair<int, int> >; std::set<_Key, _Compare, _Alloc>::value_type = std::pair<int, int>]
       insert(const_iterator __position, const value_type& __x)
       ^~~~~~
/usr/include/c++/7/bits/stl_set.h:536:7: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/7/bits/stl_set.h:541:7: note: candidate: std::set<_Key, _Compare, _Alloc>::iterator std::set<_Key, _Compare, _Alloc>::insert(std::set<_Key, _Compare, _Alloc>::const_iterator, std::set<_Key, _Compare, _Alloc>::value_type&&) [with _Key = std::pair<int, int>; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<int, int> >; std::set<_Key, _Compare, _Alloc>::iterator = std::_Rb_tree_const_iterator<std::pair<int, int> >; std::set<_Key, _Compare, _Alloc>::const_iterator = std::_Rb_tree_const_iterator<std::pair<int, int> >; std::set<_Key, _Compare, _Alloc>::value_type = std::pair<int, int>]
       insert(const_iterator __position, value_type&& __x)
       ^~~~~~
/usr/include/c++/7/bits/stl_set.h:541:7: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/7/bits/stl_set.h:556:2: note: candidate: template<class _InputIterator> void std::set<_Key, _Compare, _Alloc>::insert(_InputIterator, _InputIterator) [with _InputIterator = _InputIterator; _Key = std::pair<int, int>; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<int, int> >]
  insert(_InputIterator __first, _InputIterator __last)
  ^~~~~~
/usr/include/c++/7/bits/stl_set.h:556:2: note:   template argument deduction/substitution failed:
holiday.cpp:69:23: note:   candidate expects 2 arguments, 1 provided
    s.insert({val[i],i});
                       ^
In file included from /usr/include/c++/7/set:61:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:87,
                 from holiday.cpp:1:
/usr/include/c++/7/bits/stl_set.h:568:7: note: candidate: void std::set<_Key, _Compare, _Alloc>::insert(std::initializer_list<_Tp>) [with _Key = std::pair<int, int>; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<int, int> >]
       insert(initializer_list<value_type> __l)
       ^~~~~~
/usr/include/c++/7/bits/stl_set.h:568:7: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::initializer_list<std::pair<int, int> >'
/usr/include/c++/7/bits/stl_set.h:588:7: note: candidate: std::set<_Key, _Compare, _Alloc>::insert_return_type std::set<_Key, _Compare, _Alloc>::insert(std::set<_Key, _Compare, _Alloc>::node_type&&) [with _Key = std::pair<int, int>; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<int, int> >; std::set<_Key, _Compare, _Alloc>::insert_return_type = std::_Node_insert_return<std::_Rb_tree_const_iterator<std::pair<int, int> >, std::_Node_handle<std::pair<int, int>, std::pair<int, int>, std::allocator<std::_Rb_tree_node<std::pair<int, int> > > > >; std::set<_Key, _Compare, _Alloc>::node_type = std::_Node_handle<std::pair<int, int>, std::pair<int, int>, std::allocator<std::_Rb_tree_node<std::pair<int, int> > > >]
       insert(node_type&& __nh)
       ^~~~~~
/usr/include/c++/7/bits/stl_set.h:588:7: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::set<std::pair<int, int> >::node_type&& {aka std::_Node_handle<std::pair<int, int>, std::pair<int, int>, std::allocator<std::_Rb_tree_node<std::pair<int, int> > > >&&}'
/usr/include/c++/7/bits/stl_set.h:593:7: note: candidate: std::set<_Key, _Compare, _Alloc>::iterator std::set<_Key, _Compare, _Alloc>::insert(std::set<_Key, _Compare, _Alloc>::const_iterator, std::set<_Key, _Compare, _Alloc>::node_type&&) [with _Key = std::pair<int, int>; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<int, int> >; std::set<_Key, _Compare, _Alloc>::iterator = std::_Rb_tree_const_iterator<std::pair<int, int> >; std::set<_Key, _Compare, _Alloc>::const_iterator = std::_Rb_tree_const_iterator<std::pair<int, int> >; std::set<_Key, _Compare, _Alloc>::node_type = std::_Node_handle<std::pair<int, int>, std::pair<int, int>, std::allocator<std::_Rb_tree_node<std::pair<int, int> > > >]
       insert(const_iterator __hint, node_type&& __nh)
       ^~~~~~
/usr/include/c++/7/bits/stl_set.h:593:7: note:   candidate expects 2 arguments, 1 provided
holiday.cpp:33:6: warning: unused variable 'left' [-Wunused-variable]
  int left = 0;
      ^~~~
holiday.cpp:72:2: warning: no return statement in function returning non-void [-Wreturn-type]
  }
  ^
holiday.cpp: At global scope:
holiday.cpp:73:2: error: expected unqualified-id before 'return'
  return ans;       
  ^~~~~~
holiday.cpp:74:1: error: expected declaration before '}' token
 }
 ^