husain_Motaz's blog

By husain_Motaz, history, 17 months ago, In English

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

  • Vote: I like it
  • -1
  • Vote: I do not like it