How to solve the Maximum Product problem?

Revision en1, by husain_Motaz, 2023-07-30 20:56:01

how can i solve the Maximum Product problem the link of the problem :https://codeforces.net/gym/454092/problem/A and here is my code:

include

using namespace std;

int main() { long long arraySize = 0; long long maxProduct = 0; cin >> arraySize;

long long arr[arraySize];

for (int i=0;i<arraySize;i++) {
    cin >> arr[i];

}//end for -looping around the arraySize-

for (int j=0;j<arraySize;j++) {
    if (arr[j]*arr[j+1]>=maxProduct) {
       maxProduct = arr[j] * arr[j + 1];
    }
}//end for -searching for the max pair-

cout << maxProduct << endl;
return 0;

}//end main

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English husain_Motaz 2023-07-30 20:56:01 658 Initial revision (published)