-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLightoj 1447.cpp
52 lines (41 loc) · 1016 Bytes
/
Lightoj 1447.cpp
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
//
// main.cpp
// Hello.cpp
//
// Created by Raihan on 8/11/22.
//
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
int arr[20005];
int visitedArray[20005];
int main(int argc, const char * argv[]) {
int tes, o = 0;
cin >> tes;
while(tes--){
o++;
int n;
vector <int> takenArray;
map< int, bool> mp;
cin >> n;
long long int sum = 0;
for(int i = 0; i < n; i++){
cin >> arr[i];
}
reverse(arr, arr + n);
for(int i = 0; i < n; i++){
int sumValue = arr[i];
int absValue = arr[i];
if(absValue < 0){
absValue = absValue * (-1);
}
if(mp[absValue] == false){
sum += sumValue;
mp[absValue] = true;
}
}
printf("Case %d: %lld\n", o, sum);
}
}