Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //============================================================================
- // Name : HelloWorld.cpp
- // Author : smalinux
- // Version :
- // Copyright : Your copyright notice
- // Description : Hello World in C++, Ansi-style
- //============================================================================
- #include <iostream>
- #include <string>
- #include<iomanip>
- using namespace std;
- int main() {
- // ----------------------------------------------------------------------
- unsigned long long int N = 0;
- long long int arr[100000];
- long long int sum = 0;
- // - Insertion
- cin >> N;
- if(N >= 1 && N <= 1e5)
- for(unsigned long long int i = 0; i < N; i++)
- cin>> arr[i];
- // - Output
- for(unsigned long long int i = 0; i < N; i++) {
- if(arr[i] < -1e9 || arr[i] > 1e9 ) return -1;
- sum += arr[i];
- }
- // absolute sum
- if(sum < 0)
- sum *= -1;
- cout << sum;
- // ----------------------------------------------------------------------
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement