-
-
Notifications
You must be signed in to change notification settings - Fork 109
Expand file tree
/
Copy pathAbsoluteElementSums.java
More file actions
29 lines (28 loc) · 719 Bytes
/
AbsoluteElementSums.java
File metadata and controls
29 lines (28 loc) · 719 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int a[] = new int[n];
for(int i=0;i<n;i++){
a[i] = sc.nextInt();
}
int m = sc.nextInt();
int b[] = new int[m];
for(int i=0;i<m;i++){
b[i] = sc.nextInt();
}
for(int i=0;i<m;i++){
int sum=0;
for(int j=0;j<n;j++){
a[j] = a[j] + b[i];
sum = sum + Math.abs(a[j]);
}
System.out.println(sum);
}
}
}