Submission #1301231

#TimeUsernameProblemLanguageResultExecution timeMemory
1301231tryharderforioi100Pilot (NOI19_pilot)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; typedef int ll; #define endl "\n" int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); ll t = 1; //cin >> t; while(t--) { ll n, q; cin >> n >> q; ll a[n + 1], i; vector<pair<ll, ll>>sapxep1; for(i = 1; i <= n; i++) { cin >> a[i]; sapxep1.push_back(make_pair(a[i], i)); } sort(sapxep1.begin(), sapxep1.end()); ll ans[q + 1]; vector<pair<ll, ll>>sapxep; for(i = 1; i <= q; i++) { ll val; cin >> val; sapxep.push_back(make_pair(val, i)); } sort(sapxep.begin(), sapxep.end()); set<ll>pos; for(i = 1; i <= n; i++) { pos.insert(i); } pos.insert(0); pos.insert(n + 1); ll ans1 = 0, vtri = 0; for(i = 0; i < sapxep.size(); i++) { while(vtri < sapxep1.size() && sapxep1[vtri].first <= sapxep[i].first) { auto it = pos.lower_bound(sapxep1[vtri].second); auto it1 = it; auto it2 = it; it1--; it2++; ans1 += max(0LL, (*it2 - *it) * (*it - *it1)); vtri++; pos.erase(it); //cout << vtri << " " << ans1 << " " << i << " " << *it << " " << *it1 << " " << *it2 << endl; } ans[sapxep[i].second] = ans1; } for(i = 1; i <= q; i++) { cout << ans[i] << endl; } cout << endl; } #ifndef ONLINE_JUDGE cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"; #endif return 0; } // Author: tryharderforioi100

Compilation message (stderr)

pilot.cpp: In function 'int main()':
pilot.cpp:50:44: error: no matching function for call to 'max(long long int, int)'
   50 |                                 ans1 += max(0LL, (*it2 - *it) * (*it - *it1));
      |                                         ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/13/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51,
                 from pilot.cpp:1:
/usr/include/c++/13/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
pilot.cpp:50:44: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   50 |                                 ans1 += max(0LL, (*it2 - *it) * (*it - *it1));
      |                                         ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:303:5: note:   template argument deduction/substitution failed:
pilot.cpp:50:44: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   50 |                                 ans1 += max(0LL, (*it2 - *it) * (*it - *it1));
      |                                         ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/13/algorithm:61:
/usr/include/c++/13/bits/stl_algo.h:5795:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5795 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5795:5: note:   template argument deduction/substitution failed:
pilot.cpp:50:44: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   50 |                                 ans1 += max(0LL, (*it2 - *it) * (*it - *it1));
      |                                         ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algo.h:5805:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5805 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5805:5: note:   template argument deduction/substitution failed:
pilot.cpp:50:44: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   50 |                                 ans1 += max(0LL, (*it2 - *it) * (*it - *it1));
      |                                         ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~