logo AlgoBeat OnlineJudge
登录 注册

#206186. [NWRRC 2017] Joker

内存限制:512 MiB 时间限制:3000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

Joker prepares a new card trick with a strong mathematical background. You are asked to help Joker with calculations.

There is a row of cards with non-zero numbers written on them. Let's call the sum of all positive numbers and the sum of all negative numbers . Every card has a weight if and otherwise.

Let's denote . Joker needs to know positive with the largest If there is more than one such , he is interested in the smallest one.

But static tricks are boring, so Joker wants to change numbers on some cards, and after each change he needs to known where is the largest is.

输入格式

The first line of the input contains two integers and -- the number of cards and the number of changes .

The second line consists of integers -- numbers written on cards at the beginning .

The following lines contain two integers each: and that means value of card at position is changed to ; .

It is guaranteed that at each moment there is at least one card with positive number and at least one card with negative number. The sum of all positive cards will never exceed and the sum of all negative cards will never exceed

输出格式

You should output integers. The first integer is the position of the largest for the initial numbers. Next numbers are positions of the largest after each change.

样例

样例输入 1

4 7
1 -5 3 -5
4 -1
2 -1
3 10
4 10
1 -1
2 1
3 -1

样例输出 1

3
1
3
3
1
4
4
4

数据范围与提示

Time limit: 3 s, Memory limit: 512 MB.