{"id":"11805b48-aafe-427b-beb3-826dc58be3d6","name":"Max Sum In The Configuration","description":"1. Given an array, you have to find the max sum of i*A[i] where A[i] is the element at index i in the array. \r\n2. The only operation allowed is to rotate(clock-wise or counter clock-wise) the array any number of times.","inputFormat":"Input is managed for you","outputFormat":"Output is managed for you","constraints":"1 &lt;= N &lt;= 10^6\r\n1 &lt;= arr[i] &lt;= 10^5","sampleCode":{"cpp":{"code":"#include<bits/stdc++.h>\nusing namespace std;\n\nint maximise(vector<int>& arr)\n{\n// write your code here\n}\n\nint main()\n{\n int n;\n cin>>n;\n \n vector<int> arr(n,0);\n for(int i =0;i<n;i++)\n {\n cin>>arr[i];\n }\n \n int ans = maximise(arr);\n cout<<ans;\n \n}"},"java":{"code":"import java.util.*;\r\n\r\npublic class Main {\r\n\r\n public static int maximise(int[]arr) {\r\n //write your code here\r\n return 0;\r\n }\r\n\r\n public static void main(String[]args) {\r\n //input work\r\n Scanner scn = new Scanner(System.in);\r\n int n = scn.nextInt();\r\n\r\n int[]arr = new int[n];\r\n for(int i = 0 ; i < n; i++) {\r\n arr[i] = scn.nextInt();\r\n }\r\n\r\n int ans = maximise(arr);\r\n System.out.println(ans);\r\n }\r\n}"},"python":{"code":"def main():\r\n pass\r\n\r\nif_name_=='__main__':\r\n main()"}},"points":10,"difficulty":"medium","sampleInput":"4\r\n8 3 1 2","sampleOutput":"29","questionVideo":"https://www.youtube.com/embed/yroWfS5P2E4","hints":[],"associated":[],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"cb36811c-9cd7-4d80-aa52-ae9b8409862a","name":"Searching And Sorting For Intermediate","slug":"searching-and-sorting-for-intermediate-10001","type":0},{"id":"c5119a97-93e2-411e-a4e8-2bfa3676faf4","name":"Max Sum In The Configuration","slug":"max-sum-in-the-configuration","type":1}],"next":{"id":"1d132e50-b6bb-4e4c-8863-0605bae36007","name":"Max Sum In The Configuration","type":3,"slug":"max-sum-in-the-configuration"},"prev":{"id":"314b2d55-221b-45af-9b32-cc5dacd961d1","name":"Maximize Sum Of Arr[i]*i Of An Array MCQ","type":0,"slug":"maximize-sum-of-arr-i-i-of-an-array-mcq"}}}

Max Sum In The Configuration

1. Given an array, you have to find the max sum of i*A[i] where A[i] is the element at index i in the array. 2. The only operation allowed is to rotate(clock-wise or counter clock-wise) the array any number of times.

{"id":"11805b48-aafe-427b-beb3-826dc58be3d6","name":"Max Sum In The Configuration","description":"1. Given an array, you have to find the max sum of i*A[i] where A[i] is the element at index i in the array. \r\n2. The only operation allowed is to rotate(clock-wise or counter clock-wise) the array any number of times.","inputFormat":"Input is managed for you","outputFormat":"Output is managed for you","constraints":"1 &lt;= N &lt;= 10^6\r\n1 &lt;= arr[i] &lt;= 10^5","sampleCode":{"cpp":{"code":"#include<bits/stdc++.h>\nusing namespace std;\n\nint maximise(vector<int>& arr)\n{\n// write your code here\n}\n\nint main()\n{\n int n;\n cin>>n;\n \n vector<int> arr(n,0);\n for(int i =0;i<n;i++)\n {\n cin>>arr[i];\n }\n \n int ans = maximise(arr);\n cout<<ans;\n \n}"},"java":{"code":"import java.util.*;\r\n\r\npublic class Main {\r\n\r\n public static int maximise(int[]arr) {\r\n //write your code here\r\n return 0;\r\n }\r\n\r\n public static void main(String[]args) {\r\n //input work\r\n Scanner scn = new Scanner(System.in);\r\n int n = scn.nextInt();\r\n\r\n int[]arr = new int[n];\r\n for(int i = 0 ; i < n; i++) {\r\n arr[i] = scn.nextInt();\r\n }\r\n\r\n int ans = maximise(arr);\r\n System.out.println(ans);\r\n }\r\n}"},"python":{"code":"def main():\r\n pass\r\n\r\nif_name_=='__main__':\r\n main()"}},"points":10,"difficulty":"medium","sampleInput":"4\r\n8 3 1 2","sampleOutput":"29","questionVideo":"https://www.youtube.com/embed/yroWfS5P2E4","hints":[],"associated":[],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"cb36811c-9cd7-4d80-aa52-ae9b8409862a","name":"Searching And Sorting For Intermediate","slug":"searching-and-sorting-for-intermediate-10001","type":0},{"id":"c5119a97-93e2-411e-a4e8-2bfa3676faf4","name":"Max Sum In The Configuration","slug":"max-sum-in-the-configuration","type":1}],"next":{"id":"1d132e50-b6bb-4e4c-8863-0605bae36007","name":"Max Sum In The Configuration","type":3,"slug":"max-sum-in-the-configuration"},"prev":{"id":"314b2d55-221b-45af-9b32-cc5dacd961d1","name":"Maximize Sum Of Arr[i]*i Of An Array MCQ","type":0,"slug":"maximize-sum-of-arr-i-i-of-an-array-mcq"}}}
plane

Editor


Loading...

Max Sum In The Configuration

medium

1. Given an array, you have to find the max sum of i*A[i] where A[i] is the element at index i in the array. 2. The only operation allowed is to rotate(clock-wise or counter clock-wise) the array any number of times.

Constraints

1 <= N <= 10^6 1 <= arr[i] <= 10^5

Format

Input

Input is managed for you

Output

Output is managed for you

Example

Sample Input

4 8 3 1 2

Sample Output

29

Question Video

Discussions

Show Discussion

Related Resources

related resources

Turning Off Zen Mode