I have the brute force solution and it passed all the testcases .
Can someone help me in optimizing it more.
@carre @everule1 or anyone who can help
Thank You.
I have the brute force solution and it passed all the testcases .
Can someone help me in optimizing it more.
@carre @everule1 or anyone who can help
Thank You.
Editorial was already given along with the problem.
#include <bits/stdc++.h>
using namespace std;
int main() {
int N, T;
cin >> N >> T;
vector <int> width(N);
for(int i = 0; i < N; ++i) {
cin >> width[i];
}
for(int i = 0; i < T; ++i) {
int l, r;
cin >> l >> r;
int ans = width[l];
while(l <= r) {
ans = min(ans, width[l]);
l++;
}
cout << ans << "\n";
}
return 0;
}
That Solution was written by me. I think you didn’t understood my question .Anyways suman has helped me out. Thanks for your time.