제출 #399400

#제출 시각아이디문제언어결과실행 시간메모리
399400AugustinasJucasHiring (IOI09_hiring)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #pragma GCC optimize("O3") using namespace std; int n; long long w; vector<pair<double, pair<int, int> > > dals[20010]; int main(){ cin.tie(NULL); ios_base::sync_with_stdio(false); cin >> n >> w; for(int j = 0; j < n; j++){ int s, q; cin >> s >> q; int sq = sqrt(q); int sk; long double kaina; for(int i = 1; i <= sq; i++) { if(q % i != 0) continue; sk = i; kaina = (1.0 * s) / (1.0 * (q/i)); dals[sk].push_back({kaina, {q/i, j}}); if(i * i == q) continue; sk = q/i; kaina = (1.0 * s) / (1.0 * i); dals[sk].push_back({kaina, {i, j}}); } } pair<pair<int, long double>, pair<int, int> > mx = {{0 , 0}, {-1, -1}}; int i1 = 0; for(auto &x : dals){ if(x.size() == 0){ i1++; continue; } sort(x.begin(), x.end()); multiset<int> cur; long long sm = 0; int i2 = 0; // cout << "darau " << i1 << endl; // cout << "X: "; for(auto y : x) cout << y.second.first << " "; // cout << endl; for(auto y : x){ cur.insert(y.second.first); sm += y.second.first; while((long double) sm * y.first > w){ sm -= *cur.rbegin(); cur.erase(cur.find(*cur.rbegin())); } // cout << "po " << i2 << ", cure yra " << cur.size() << ", sm = " << sm << ", kaina = " << y.first << endl; mx = max(mx, make_pair(make_pair((int)cur.size(), -(double) sm * y.first), make_pair(i1, i2))); i2++; } // cout << ", po jo mx = " << mx.first.first << "\n\n"; i1++; } i1 = mx.second.first; int i2 = mx.second.second; vector<pair<int, int> > cur; for(int i = 0; i <= i2; i++){ cur.push_back({(long double)dals[i1][i].second.first, dals[i1][i].second.second}); } sort(cur.begin(), cur.end()); cout << mx.first.first << "\n"; for(int i = 0; i < min((int)cur.size(), mx.first.first); i++){ cout << cur[i].second +1<< " "; } return 0; }

컴파일 시 표준 에러 (stderr) 메시지

hiring.cpp: In function 'int main()':
hiring.cpp:49:106: error: no matching function for call to 'max(std::pair<std::pair<int, long double>, std::pair<int, int> >&, std::pair<std::pair<int, double>, std::pair<int, int> >)'
   49 |             mx = max(mx, make_pair(make_pair((int)cur.size(), -(double) sm * y.first), make_pair(i1, i2)));
      |                                                                                                          ^
In file included from /usr/include/c++/9/bits/char_traits.h:39,
                 from /usr/include/c++/9/ios:40,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from hiring.cpp:1:
/usr/include/c++/9/bits/stl_algobase.h:222:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  222 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:222:5: note:   template argument deduction/substitution failed:
hiring.cpp:49:106: note:   deduced conflicting types for parameter 'const _Tp' ('std::pair<std::pair<int, long double>, std::pair<int, int> >' and 'std::pair<std::pair<int, double>, std::pair<int, int> >')
   49 |             mx = max(mx, make_pair(make_pair((int)cur.size(), -(double) sm * y.first), make_pair(i1, i2)));
      |                                                                                                          ^
In file included from /usr/include/c++/9/bits/char_traits.h:39,
                 from /usr/include/c++/9/ios:40,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from hiring.cpp:1:
/usr/include/c++/9/bits/stl_algobase.h:268:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  268 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:268:5: note:   template argument deduction/substitution failed:
hiring.cpp:49:106: note:   deduced conflicting types for parameter 'const _Tp' ('std::pair<std::pair<int, long double>, std::pair<int, int> >' and 'std::pair<std::pair<int, double>, std::pair<int, int> >')
   49 |             mx = max(mx, make_pair(make_pair((int)cur.size(), -(double) sm * y.first), make_pair(i1, i2)));
      |                                                                                                          ^
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from hiring.cpp:1:
/usr/include/c++/9/bits/stl_algo.h:3456:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3456 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/9/bits/stl_algo.h:3456:5: note:   template argument deduction/substitution failed:
hiring.cpp:49:106: note:   'std::pair<std::pair<int, long double>, std::pair<int, int> >' is not derived from 'std::initializer_list<_Tp>'
   49 |             mx = max(mx, make_pair(make_pair((int)cur.size(), -(double) sm * y.first), make_pair(i1, i2)));
      |                                                                                                          ^
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from hiring.cpp:1:
/usr/include/c++/9/bits/stl_algo.h:3462:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3462 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algo.h:3462:5: note:   template argument deduction/substitution failed:
hiring.cpp:49:106: note:   'std::pair<std::pair<int, long double>, std::pair<int, int> >' is not derived from 'std::initializer_list<_Tp>'
   49 |             mx = max(mx, make_pair(make_pair((int)cur.size(), -(double) sm * y.first), make_pair(i1, i2)));
      |                                                                                                          ^