text: Minimize total time taken by two persons to visit N cities such that none of them meet | C # program for the above approach ; Function to find the minimum time to visit all the cities such that both the person never meets ; Initialize sum as 0 ; Find the maximum element ; Traverse the array ; Increment sum by arr [ i ] ; Print maximum of 2 * T and sum ; Driver code ; Function Call
code: using System ; using System . Linq ; class GFG { static void minimumTime ( int [ ] arr , int n ) { int sum = 0 ; int T = arr . Min ( ) ; for ( int i = 0 ; i < n ; i ++ ) { sum += arr [ i ] ; } Console . WriteLine ( Math . Max ( 2 * T , sum ) ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 2 , 8 , 3 } ; int N = arr . Length ; minimumTime ( arr , N ) ; } }