Source Code
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;

int main()
{
    int n,k;
    long long  arr[1000001];
    cin>>n>>k;
    for(int i=0;i<n;i++)
    cin>>arr[i];
    sort(arr,arr+n);
    cout<<arr[n-1]+arr[0];
}
   /* long long  n,k;
    cin>>n>>k;
    
    long long arr[1000001];
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    if(n==1)
    cout<<arr[0];
    else
    {
    long long sum=0;
    sort(arr,arr+n);
    if(n%2==0)
    {
        for(int j=0;j<n;j+=k)
        sum+=arr[j];
    }
    else
    {
        for(int j=1;j<n;j+=k)
        sum+=arr[j];
    }
    cout<<sum;
    }
}*/
Copy
Offer Nada M
GNU G++17
9 ms
8.0 MB
Wrong Answer