Redundant or Not? - Hacker Rank Program

Problem Statement
You are given a list of N numbers, {a1,a2,,aN}, to be added to a database.
Each of these numbers must be added to the database in the order in which they are given.
If a number has already been added to the database, print "REDUNDANT" (without quotation marks).
Otherwise, add it to the database and print "ADDED"(again, without quotation marks).
The answer of each operation should be printed in a new line.
Input Format
The first line contains a single integer N, denoting the number of numbers to be added.
The second line contains the N space-separated integers - a1,a2,aN.
Output Format
N lines, each having the answer to the subsequent operation.
Constraints
  • 1N105
  • 109ai109, where i[1,N]
Sample Input
5
4
3
-3
3
100000
Sample Output
ADDED
ADDED
ADDED
REDUNDANT
ADDED
Explanation
  1. After the first addition, the database is now [4].
  2. After the second addition, the database is now [3,4].
  3. After the third addition, the database is now [-3,3,4].
  4. In the fourth addition, since 3 is already in the database, the database is now [-3,3,4].
  5. After the fifth addition, the database is now [-3,3,4,100000].
My Solution:

#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;

long int neg[1000000]={0},pos[1000000]={0};
int main() {
    long int t;
    cin>>t;
   
    while(t--)
    {
        long int val;
        cin>>val;
        if(val>=0)
        {
          if(pos[val]==0)
              {
              printf("ADDED\n");
              pos[val]=1; 
          }
            else
               {
                printf("REDUNDANT\n");
            }
          }
        else
            {
            val=val*-1;
            if(neg[val]==0)
              {
              printf("ADDED\n");
              neg[val]=1; 
          }
            else
               {
                printf("REDUNDANT\n");
            }
        }
    }
    return 0;
}

Convert resultset object to list of map

Convert the resultset object to list of map In some cases, while we doing API automation, we need to fetch the value from the DB and hav...