Official

A - Second Half Sum Editorial by physics0523


初心者の方へ

原案: admin

以下の \(2\) 点を組み合わせるとこの問題に正解できます。

  1. 配列 \(A\) を標準入力から受け取る
  2. 配列 \(A\) の後半部分の総和を取り、出力する

例えば、これらの双方に for ループを活用することができます。

実装例 (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;
}