9472 | 2024-02-22 09:31:24 | csaron71 | Bányász RPG (40 pont) | cpp17 | Forditási hiba |
#include <bits/stdc++.h>
using namespace std;
int main() {
long long n;
cin >> n;
vector<long long> kell;
vector<pair<long long, long long> > kovek;
for (long long i=0; i<n; i++) {
long long x;
cin >> x;
kell.push_back(x);
}
for (long long i=0; i<n; i++) {
long long x;
cin >> x;
kovek.push_back({kell[i], x});
}
sort(kovek.begin(), kovek.end());
deque<pair<long long, long long> > sor; // szint, hany
for (auto sz : kovek) {
sor.push_back(sz);
}
long long szint=0;
long long ido=0;
while (sor.size()>1) {
if (szint>=sor.front().first) {
szint+=sor.front().second;
ido+=sor.front().second;
sor.pop_front();
}
else {
if (szint+sor.back().second<sor.front().first) {
szint+=sor.back().second;
ido+=2*sor.back().second;
sor.pop_back();
}
else {
long long sorvegf = sor.back().first;
long long sorvegs = sor.back().second;
sor.pop_back();
long long utso=sor.front().first-szint;
sorvegs-=utso;
szint=sor.front().first;
ido+=2*utso;
sor.push_back({sorvegf, sorvegs});
}
}
//cout << "\n" << szint << " TIME: " << ido << "\n";
}
long long kelloszint=sor.front().first;
long long db=sor.front().second;
//cout << "Szint: " << szint << " cel: " << kelloszint << " DB: " << db << "\n";
if (kelloszint-szint<db) {
long long meg=db-(max (kelloszint-szint, 0));
ido+=2*(max(kelloszint-szint, 0));
ido+=meg;
}
else {
ido+=2*db;
}
cout << ido << " \n";
}
exit status 1
main.cpp: In function 'int main()':
main.cpp:57:31: error: no matching function for call to 'max(long long int, int)'
57 | long long meg=db-(max (kelloszint-szint, 0));
| ~~~~^~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/bits/specfun.h:45,
from /usr/include/c++/11/cmath:1935,
from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
from main.cpp:1:
/usr/include/c++/11/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
254 | max(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/11/bits/stl_algobase.h:254:5: note: template argument deduction/substitution failed:
main.cpp:57:31: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
57 | long long meg=db-(max (kelloszint-szint, 0));
| ~~~~^~~~~~~~~~~~~~~~~~~~~
In file included from /...