8604 | 2024-01-23 10:09:45 | Ghost | Leggyorsabb pénzkeresés (50) | cpp17 | Forditási hiba |
#include <iostream>
#include <vector>
#include <algorithm>
#include <limits>
using namespace std;
int main()
{
int n, p, i, temp;
cin >> n >> p;
vector<pair<int,int>> pay(n);
vector<int> pay2(n);
for (i = 0; i < n; i++) {
cin >> temp;
pay[i].first = temp;
pay[i].second = i;
pay2[i] = temp;
}
sort(pay.begin(), pay.end());
i = 0;
int minday = INT_MAX;
while (i < n) {
int node = pay[i].second, value = pay[i].first, days = 1;
bool canR = false, canL = false;
if (value >= p) {
cout << days;
return 0;
}
if (node < n - 1) {
canR = true;
}
if (node > 0) {
canL = true;
}
int r = 1, l = 1;
while (value < p && (canL || canR)) {
int R = -1, L = -1;
if (canR) {
R = pay2[node + r];
}
if (canL) {
L = pay2[node - l];
}
if (R >= L && canR) {
value += R;
r++;
days++;
if ((node + r) >= n) {
canR = false;
}
}
else if (canL) {
value += L;
l++;
days++;
if ((node - l) <= 0) {
canL = false;
}
}
}
if (days < minday) {
minday = days;
}
i++;
}
cout << minday;
}
exit status 1
main.cpp: In function 'int main()':
main.cpp:25:18: error: 'INT_MAX' was not declared in this scope
25 | int minday = INT_MAX;
| ^~~~~~~
main.cpp:5:1: note: 'INT_MAX' is defined in header '<climits>'; did you forget to '#include <climits>'?
4 | #include <limits>
+++ |+#include <climits>
5 |
Exited with error status 1