Please sign in first.
			
		
		
	
		Official
		
		
			
		
		
			
	
B - Weekly Records Editorial by en_translator
For beginners
- If you are new to learning programming and do not know where to start, please try Problem A "Welcome to AtCoder" from practice contest.  There you can find a sample code for each language.  
 
- Also, if you are not familiar with problems in programming contests, we recommend you to try some problems in "AtCoder Beginners Selection".  
 
- 「競プロ典型 90 問」(Typical 90 Problems of Competitive Programming) is a collection of typical 90 competitive programming problems; unfortunately, currently the problem statements are all Japanese.  
 
- 「C++入門 AtCoder Programming Guide for beginners (APG4b)」 is a C++ tutorial for competitive programmers.  Sadly, this is only in Japanese too.
 
This problem can be solved with an array and a for statement. We recommend you to review how to use an array and a for statement in your language.
In order to find the sum of steps for seven days, you can use a for statement to loop seven times, or use a built-in function like sum.
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin >> n;
	vector<int>a(7*n);
	for(int i=0;i<7*n;i++)cin >> a[i];
	for(int i=0;i<n;i++){
		int sum=0;
		for(int j=0;j<7;j++)sum+=a[7*i+j];
		if(i!=n-1){
			cout << sum << ' ';
		}else {
			cout << sum << endl;
		}
	}
}
N=int(input())
A=list(map(int,input().split()))
for i in range(N):
  sum=0
  for j in range(7):
    sum+=A[7*i+j]
  if i!=N-1:
    print(sum,end=" ")
  else:
    print(sum,end="\n")
N=int(input())
A=list(map(int,input().split()))
ans=[sum(A[7*i:7*i+7]) for i in range(N)]
print(*ans)
				posted:
				
				
				last update: