# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1154032 | Sandarach151 | Akcija (COCI21_akcija) | C++20 | Compilation error | 0 ms | 0 KiB |
#include<bits/stdc++.h>
using namespace std;
#define int long long
struct info{
int count;
int weight;
int empty;
info(int a, int b, int c): count(a), weight(b), empty(c) {}
info(){
count=0;
weight=0;
empty=0;
}
};
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n, k;
cin >> n >> k;
pair<int, int> arr[n];
for(int i=0; i<n; i++){
int w, d;
cin >> w >> d;
arr[i] = make_pair(d-1, w);
}
sort(arr, arr+n);
multiset<int, vector<int>, greater<int>> used;
info dp[n];
dp[0] = info(1, arr[0].second, arr[0].first);
used.insert(arr[0].second);
for(int i=1; i<n; i++){
if(arr[i].first != arr[i-1].first){
int cnt = dp[i-1].count+1;
int wght = dp[i-1].weight+arr[i].second;
int empty = dp[i-1].empty+(arr[i].first-arr[i-1].first-1);
dp[i] = info(cnt, wght, empty);
used.insert(arr[i].second);
}
else{
if(dp[i-1].empty>0){
int cnt = dp[i-1].count+1;
int wght = dp[i-1].weight+arr[i].second;
int empty = dp[i-1].empty-1;
dp[i] = info(cnt, wght, empty);
used.insert(arr[i].second);
}
else{
if(arr[i].second < *used.begin()){
int wght = dp[i-1].weight - *used.begin() + arr[i].second;
used.delete(used.begin());
used.insert(arr[i].second);
dp[i] = dp[i-1];
dp[i].weight = wght;
}
else{
dp[i] = dp[i-1];
}
}
}
}
cout << dp[n-1].count << ' ' << dp[n-1].weight << '\n';
return 0;
}
Compilation message (stderr)
In file included from /usr/include/c++/11/set:62, from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:87, from Main.cpp:1: /usr/include/c++/11/bits/stl_multiset.h: In instantiation of 'class std::multiset<long long int, std::vector<long long int>, std::greater<long long int> >': Main.cpp:31:43: required from here /usr/include/c++/11/bits/stl_multiset.h:113:65: error: no type named 'value_type' in 'struct std::greater<long long int>' 113 | static_assert(is_same<typename _Alloc::value_type, _Key>::value, | ^~~~~ /usr/include/c++/11/bits/stl_multiset.h:129:29: error: no type named 'value_type' in 'struct std::greater<long long int>' 129 | rebind<_Key>::other _Key_alloc_type; | ^~~~~~~~~~~~~~~ /usr/include/c++/11/bits/stl_multiset.h:132:54: error: no type named 'value_type' in 'struct std::greater<long long int>' 132 | key_compare, _Key_alloc_type> _Rep_type; | ^~~~~~~~~ /usr/include/c++/11/bits/stl_multiset.h:136:58: error: no type named 'value_type' in 'struct std::greater<long long int>' 136 | typedef __gnu_cxx::__alloc_traits<_Key_alloc_type> _Alloc_traits; | ^~~~~~~~~~~~~ /usr/include/c++/11/bits/stl_multiset.h:139:58: error: no type named 'value_type' in 'struct std::greater<long long int>' 139 | typedef typename _Alloc_traits::pointer pointer; | ^~~~~~~ /usr/include/c++/11/bits/stl_multiset.h:140:58: error: no type named 'value_type' in 'struct std::greater<long long int>' 140 | typedef typename _Alloc_traits::const_pointer const_pointer; | ^~~~~~~~~~~~~ /usr/include/c++/11/bits/stl_multiset.h:141:58: error: no type named 'value_type' in 'struct std::greater<long long int>' 141 | typedef typename _Alloc_traits::reference reference; | ^~~~~~~~~ /usr/include/c++/11/bits/stl_multiset.h:142:58: error: no type named 'value_type' in 'struct std::greater<long long int>' 142 | typedef typename _Alloc_traits::const_reference const_reference; | ^~~~~~~~~~~~~~~ /usr/include/c++/11/bits/stl_multiset.h:146:58: error: no type named 'value_type' in 'struct std::greater<long long int>' 146 | typedef typename _Rep_type::const_iterator iterator; | ^~~~~~~~ /usr/include/c++/11/bits/stl_multiset.h:147:58: error: no type named 'value_type' in 'struct std::greater<long long int>' 147 | typedef typename _Rep_type::const_iterator const_iterator; | ^~~~~~~~~~~~~~ /usr/include/c++/11/bits/stl_multiset.h:148:58: error: no type named 'value_type' in 'struct std::greater<long long int>' 148 | typedef typename _Rep_type::const_reverse_iterator reverse_iterator; | ^~~~~~~~~~~~~~~~ /usr/include/c++/11/bits/stl_multiset.h:149:58: error: no type named 'value_type' in 'struct std::greater<long long int>' 149 | typedef typename _Rep_type::const_reverse_iterator const_reverse_iterator; | ^~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/11/bits/stl_multiset.h:150:58: error: no type named 'value_type' in 'struct std::greater<long long int>' 150 | typedef typename _Rep_type::size_type size_type; | ^~~~~~~~~ /usr/include/c++/11/bits/stl_multiset.h:151:58: error: no type named 'value_type' in 'struct std::greater<long long int>' 151 | typedef typename _Rep_type::difference_type difference_type; | ^~~~~~~~~~~~~~~ /usr/include/c++/11/bits/stl_multiset.h:154:13: error: no type named 'value_type' in 'struct std::greater<long long int>' 154 | using node_type = typename _Rep_type::node_type; | ^~~~~~~~~ /usr/include/c++/11/bits/stl_multiset.h:736:49: error: using invalid field 'std::multiset<_Key, _Compare, _Alloc>::_M_t' 736 | count(const _Kt& __x) const -> decltype(_M_t._M_count_tr(__x)) | ^~~~ /usr/include/c++/11/bits/stl_multiset.h:755:21: error: using invalid field 'std::multiset<_Key, _Compare, _Alloc>::_M_t' 755 | -> decltype(_M_t._M_find_tr(__x), void(), true) | ^~~~ /usr/include/c++/11/bits/stl_multiset.h:821:30: error: using invalid field 'std::multiset<_Key, _Compare, _Alloc>::_M_t' 821 | -> decltype(iterator(_M_t._M_lower_bound_tr(__x))) | ^~~~ /usr/include/c++/11/bits/stl_multiset.h:827:30: error: using invalid field 'std::multiset<_Key, _Compare, _Alloc>::_M_t' 827 | -> decltype(iterator(_M_t._M_lower_bound_tr(__x))) | ^~~~ /usr/include/c++/11/bits/stl_multiset.h:851:30: error: using invalid field 'std::multiset<_Key, _Compare, _Alloc>::_M_t' 851 | -> decltype(iterator(_M_t._M_upper_bound_tr(__x))) | ^~~~ /usr/include/c++/11/bits/stl_multiset.h:857:30: error: using invalid field 'std::multiset<_Key, _Compare, _Alloc>::_M_t' 857 | -> decltype(iterator(_M_t._M_upper_bound_tr(__x))) | ^~~~ /usr/include/c++/11/bits/stl_multiset.h:879:7: error: no type named 'value_type' in 'struct std::greater<long long int>' 879 | equal_range(const key_type& __x) | ^~~~~~~~~~~ /usr/include/c++/11/bits/stl_multiset.h:883:7: error: no type named 'value_type' in 'struct std::greater<long long int>' 883 | equal_range(const key_type& __x) const | ^~~~~~~~~~~ /usr/include/c++/11/bits/stl_multiset.h:890:21: error: no type named 'value_type' in 'struct std::greater<long long int>' 890 | -> decltype(pair<iterator, iterator>(_M_t._M_equal_range_tr(__x))) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/11/bits/stl_multiset.h:890:46: error: using invalid field 'std::multiset<_Key, _Compare, _Alloc>::_M_t' 890 | -> decltype(pair<iterator, iterator>(_M_t._M_equal_range_tr(__x))) | ^~~~ /usr/include/c++/11/bits/stl_multiset.h:896:21: error: no type named 'value_type' in 'struct std::greater<long long int>' 896 | -> decltype(pair<iterator, iterator>(_M_t._M_equal_range_tr(__x))) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/11/bits/stl_multiset.h:896:46: error: using invalid field 'std::multiset<_Key, _Compare, _Alloc>::_M_t' 896 | -> decltype(pair<iterator, iterator>(_M_t._M_equal_range_tr(__x))) | ^~~~ Main.cpp: In function 'int main()': Main.cpp:34:20: error: no matching function for call to 'std::multiset<long long int, std::vector<long long int>, std::greater<long long int> >::insert(long long int&)' 34 | used.insert(arr[0].second); | ~~~~~~~~~~~^~~~~~~~~~~~~~~ In file included from /usr/include/c++/11/set:62, from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:87, from Main.cpp:1: /usr/include/c++/11/bits/stl_multiset.h:551:9: note: candidate: 'template<class _InputIterator> void std::multiset<_Key, _Compare, _Alloc>::insert(_InputIterator, _InputIterator) [with _InputIterator = _InputIterator; _Key = long long int; _Compare = std::vector<long long int>; _Alloc = std::greater<long long int>]' 551 | insert(_InputIterator __first, _InputIterator __last) | ^~~~~~ /usr/include/c++/11/bits/stl_multiset.h:551:9: note: template argument deduction/substitution failed: Main.cpp:34:20: note: candidate expects 2 arguments, 1 provided 34 | used.insert(arr[0].second); | ~~~~~~~~~~~^~~~~~~~~~~~~~~ In file included from /usr/include/c++/11/set:62, from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:87, from Main.cpp:1: /usr/include/c++/11/bits/stl_multiset.h:563:7: note: candidate: 'void std::multiset<_Key, _Compare, _Alloc>::insert(std::initializer_list<_Tp>) [with _Key = long long int; _Compare = std::vector<long long int>; _Alloc = std::greater<long long int>]' 563 | insert(initializer_list<value_type> __l) | ^~~~~~ /usr/include/c++/11/bits/stl_multiset.h:563:43: note: no known conversion for argument 1 from 'long long int' to 'std::initializer_list<long long int>' 563 | insert(initializer_list<value_type> __l) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~ Main.cpp:41:36: error: no matching function for call to 'std::multiset<long long int, std::vector<long long int>, std::greater<long long int> >::insert(long long int&)' 41 | used.insert(arr[i].second); | ~~~~~~~~~~~^~~~~~~~~~~~~~~ In file included from /usr/include/c++/11/set:62, from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:87, from Main.cpp:1: /usr/include/c++/11/bits/stl_multiset.h:551:9: note: candidate: 'template<class _InputIterator> void std::multiset<_Key, _Compare, _Alloc>::insert(_InputIterator, _InputIterator) [with _InputIterator = _InputIterator; _Key = long long int; _Compare = std::vector<long long int>; _Alloc = std::greater<long long int>]' 551 | insert(_InputIterator __first, _InputIterator __last) | ^~~~~~ /usr/include/c++/11/bits/stl_multiset.h:551:9: note: template argument deduction/substitution failed: Main.cpp:41:36: note: candidate expects 2 arguments, 1 provided 41 | used.insert(arr[i].second); | ~~~~~~~~~~~^~~~~~~~~~~~~~~ In file included from /usr/include/c++/11/set:62, from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:87, from Main.cpp:1: /usr/include/c++/11/bits/stl_multiset.h:563:7: note: candidate: 'void std::multiset<_Key, _Compare, _Alloc>::insert(std::initializer_list<_Tp>) [with _Key = long long int; _Compare = std::vector<long long int>; _Alloc = std::greater<long long int>]' 563 | insert(initializer_list<value_type> __l) | ^~~~~~ /usr/include/c++/11/bits/stl_multiset.h:563:43: note: no known conversion for argument 1 from 'long long int' to 'std::initializer_list<long long int>' 563 | insert(initializer_list<value_type> __l) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~ Main.cpp:49:44: error: no matching function for call to 'std::multiset<long long int, std::vector<long long int>, std::greater<long long int> >::insert(long long int&)' 49 | used.insert(arr[i].second); | ~~~~~~~~~~~^~~~~~~~~~~~~~~ In file included from /usr/include/c++/11/set:62, from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:87, from Main.cpp:1: /usr/include/c++/11/bits/stl_multiset.h:551:9: note: candidate: 'template<class _InputIterator> void std::multiset<_Key, _Compare, _Alloc>::insert(_InputIterator, _InputIterator) [with _InputIterator = _InputIterator; _Key = long long int; _Compare = std::vector<long long int>; _Alloc = std::greater<long long int>]' 551 | insert(_InputIterator __first, _InputIterator __last) | ^~~~~~ /usr/include/c++/11/bits/stl_multiset.h:551:9: note: template argument deduction/substitution failed: Main.cpp:49:44: note: candidate expects 2 arguments, 1 provided 49 | used.insert(arr[i].second); | ~~~~~~~~~~~^~~~~~~~~~~~~~~ In file included from /usr/include/c++/11/set:62, from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:87, from Main.cpp:1: /usr/include/c++/11/bits/stl_multiset.h:563:7: note: candidate: 'void std::multiset<_Key, _Compare, _Alloc>::insert(std::initializer_list<_Tp>) [with _Key = long long int; _Compare = std::vector<long long int>; _Alloc = std::greater<long long int>]' 563 | insert(initializer_list<value_type> __l) | ^~~~~~ /usr/include/c++/11/bits/stl_multiset.h:563:43: note: no known conversion for argument 1 from 'long long int' to 'std::initializer_list<long long int>' 563 | insert(initializer_list<value_type> __l) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~ Main.cpp:52:58: error: 'class std::multiset<long long int, std::vector<long long int>, std::greater<long long int> >' has no member named 'begin' 52 | if(arr[i].second < *used.begin()){ | ^~~~~ Main.cpp:53:75: error: 'class std::multiset<long long int, std::vector<long long int>, std::greater<long long int> >' has no member named 'begin' 53 | int wght = dp[i-1].weight - *used.begin() + arr[i].second; | ^~~~~ Main.cpp:54:46: error: expected unqualified-id before 'delete' 54 | used.delete(used.begin()); | ^~~~~~ Main.cpp:55:52: error: no matching function for call to 'std::multiset<long long int, std::vector<long long int>, std::greater<long long int> >::insert(long long int&)' 55 | used.insert(arr[i].second); | ~~~~~~~~~~~^~~~~~~~~~~~~~~ In file included from /usr/include/c++/11/set:62, from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:87, from Main.cpp:1: /usr/include/c++/11/bits/stl_multiset.h:551:9: note: candidate: 'template<class _InputIterator> void std::multiset<_Key, _Compare, _Alloc>::insert(_InputIterator, _InputIterator) [with _InputIterator = _InputIterator; _Key = long long int; _Compare = std::vector<long long int>; _Alloc = std::greater<long long int>]' 551 | insert(_InputIterator __first, _InputIterator __last) | ^~~~~~ /usr/include/c++/11/bits/stl_multiset.h:551:9: note: template argument deduction/substitution failed: Main.cpp:55:52: note: candidate expects 2 arguments, 1 provided 55 | used.insert(arr[i].second); | ~~~~~~~~~~~^~~~~~~~~~~~~~~ In file included from /usr/include/c++/11/set:62, from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:87, from Main.cpp:1: /usr/include/c++/11/bits/stl_multiset.h:563:7: note: candidate: 'void std::multiset<_Key, _Compare, _Alloc>::insert(std::initializer_list<_Tp>) [with _Key = long long int; _Compare = std::vector<long long int>; _Alloc = std::greater<long long int>]' 563 | insert(initializer_list<value_type> __l) | ^~~~~~ /usr/include/c++/11/bits/stl_multiset.h:563:43: note: no known conversion for argument 1 from 'long long int' to 'std::initializer_list<long long int>' 563 | insert(initializer_list<value_type> __l) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~