@@ -0,0 +1,542 @@
+%5Bn,q%5D = map(int,input().split())%0A%0At = %5B 0 for _ in range(n) %5D%0A%0Amax_idx = 0%0Amax_val = 0%0A%0Afor _ in range(q):%0A    %5Ba,v%5D = map(int,input().split())%0A    t%5Ba-1%5D += v%0A%0A    if max_idx == a-1:%0A        if v %3E 0:%0A            max_val = t%5Ba-1%5D%0A        else:%0A            max_val = max(t)%0A            max_idx = t.index(max_val)%0A    elif t%5Ba-1%5D %3E max_val:%0A        max_val = t%5Ba-1%5D%0A        max_idx = a-1%0A    elif t%5Ba-1%5D == max_val:%0A        if a-1 %3C max_idx:%0A            max_val = t%5Ba-1%5D%0A            max_idx = a-1%0A%0A    print(%22%7B%7D %7B%7D%22.format(max_idx+1,max_val))%0A

solved 0099