Official

A - Second Half Sum Editorial by en_translator


For beginners

Original proposer: admin

The problem can be solved by performing the following two operations:

  1. Receive the array \(A\) from Standard Input.
  2. Take the sum of the latter half of the array \(A\), and print it.

For example, one can use for loops for both of them.

Sample code (C++):

#include<bits/stdc++.h>

using namespace std;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n,s=0;
  cin >> n;
  vector<int> a(n);
  for(auto &nx : a){cin >> nx;}
  for(int i=(n/2);i<n;i++){
    s+=a[i];
  }
  cout << s << "\n";
  return 0;
}