Compile Error
foo.cc: In function 'int main()': foo.cc:18:21: error: 'INT_MAX' was not declared in this scope 18 | int min_value = INT_MAX; | ^~~~~~~ foo.cc:3:1: note: 'INT_MAX' is defined in header '<climits>'; did you forget to '#include <climits>'? 2 | #include <vector> +++ |+#include <climits> 3 |
Code
#include <iostream>
#include <vector>
using namespace std;
int main() {
int N;
cin >> N;
vector<int> A(N);
for (int i = 0; i < N; ++i) {
cin >> A[i];
}
int Q;
cin >> Q;
int min_value = INT_MAX;
int min_index = -1;
for (int i = 0; i < N; ++i) {
if (A[i] < min_value) {
min_value = A[i];
min_index = i;
}
}
for (int i = 0; i < Q; ++i) {
cout << min_index + 1 << "\n";
int X;
cin >> X;
A[min_index] = X;
min_value = INT_MAX;
for (int j = 0; j < N; ++j) {
if (A[j] < min_value) {
min_value = A[j];
min_index = j;
}
}
}
return 0;
}
Information
- Submit By
- Type
- Submission
- Problem
- P1086 KuZ the Position
- Contest
- Bangladesh 2.0
- Language
- C++20 (G++ 13.2.0)
- Submit At
- 2024-08-16 15:58:39
- Judged At
- 2024-10-03 13:29:15
- Judged By
- Score
- 0
- Total Time
- 0ms
- Peak Memory
- 0 Bytes