#include <iostream> #include <memory> using namespace std; int main() { int n; std::cin >> n; if (n < 1) { return 0; } // unique_ptr<int[]> ptr = make_unique<int[]>(n); // int total = 0; // int avg = 0; // for(int i = 0; i < n; i++){ // total += ptr[i]; // } // cout << total << endl; // avg = total/n; // cout << avg <<endl; int* arr = new int[n]; int buffer = 0; for(int i = 0; i < n; i++){ cin >> arr[i]; buffer = buffer + arr[i]; } int avg = buffer/n; cout << avg << endl; delete[] arr; //delete[] ptr; // Write your dynamic buffer allocation code here return 0; }
Test Cases
Test Results
Input
5 10 20 30 40 50
Expected Output
30