Cookies
Ann Britt-Caroline has $N$ different types of cookies. She has $A_ i$ cookies of type $i$. Now, Ann is wondering how many cookies she has in total.
Example
In this example, we have $N = 3$ different types of cookies. The number of cookies of each type is $3, 1, 5$.
As pictured, this gives a total of $9$ different cookies.
Task
You will be given $N$ and $A$. Write a program to help Ann compute the total number of cookies. You should implement the function cookies(N, A):
-
cookies(N, A) - this function will be called exactly once by the judge.
-
N: the number of types of cookies.
-
A: a vector of length $N$. $A[i] (0 \le i < N)$ contains the number of cookies of type $i$. $A[i]$ is always positive.
-
The function should return the number of cookies Ann has.
-
A code skeleton containing the function to be implemented, together with a sample grader, can be found at http://progolymp.se/uploads/kattis-attachments/kakor.zip.
Subtasks
The problem consists of a number of subtasks. Each subtask gives some amount of points, and to pass the subtask you must pass all the test cases in the subtask.
Subtask |
Points |
Limits |
1 |
27 |
$1 \le N \le 1\, 000$, $A[i] = 1$. |
2 |
34 |
$1 \le N \le 1\, 000$, $A[i] \le 100\, 000$. |
3 |
39 |
$1 \le N \le 100\, 000$, $A[i] \le 100\, 000$. |
Input format
The sample judge reads input in the following format:
-
line 1: N
-
line 2: A[0] A[1] ... A[N - 1]
Output format
The sample judge writes the return value of cookies(A, N).
Sample Input 1 | Sample Output 1 |
---|---|
3 3 1 5 |
9 |