|시간 제한||메모리 제한||제출||정답||맞힌 사람||정답 비율|
|1 초||1024 MB||74||64||39||88.636%|
Before you graduate from your beloved university, you managed to secure an internship at a security company. Your first task is to analyze a login/logout sequence.
You are given a sequence of integers A that represents a record for users login/logout events in chronological order. Each user is represented by a unique integer. A positive integer x indicates a login event while a negative integer −x indicates a logout event by user |x|. You are guaranteed that there are no two events that are the same in A.
Once in a while, you might find from the record, a user who logs out even though that user has never been logged in previously. This can be due to a bug in the system or a hacking attempt. Nevertheless, it’s suspicious!
For example, let A1..8 = (8, 3, −8, −6, 7, −3, −1, 6). There are 8 events from 5 distinct users (the users are 1, 3, 6, 7, and 8). The events are as follows.
In total, there are 2 suspicious logout events, i.e. A4 = −6 and A7 = −1. Note that although user 6 logs in at A8, he has not logged in when he logs out at A4.
Your task in this problem is to count how many logout suspicious events are there given the login/logout record.
Input begins with a line containing an integer N (1 ≤ N ≤ 1000) representing the number of events in the given record. The next line contains N integers Ai (−1000 ≤ Ai ≤ 1000; Ai ≠ 0) each representing an event in chronological order. It is guaranteed that all integers in A are distinct.
Output contains an integer in a line representing the number of suspicious logout events.
8 8 3 -8 -6 7 -3 -1 6
4 17 -17 12 -12
4 -317 -1 -20 -300
4 27 108 36 9
4 -100 -200 200 100
ICPC > Regionals > Asia Pacific > Indonesia > Indonesia National Contest > INC 2021 A번