PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#CCBCHBAHAI0000040. Truy vết vòng for duyệt mảng (Trace an Array Traversal For Loop)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Truy vết vòng for duyệt mảng (Trace an Array Traversal For Loop)
Trace an Array Traversal For Loop
Source: Phước Hưng OJ
Version: Phuoc Hung OJ Extended
Problem Statement
You are given a one-dimensional array of integers . Consider a loop that traverses the array in increasing index order. Before the loop, set . At iteration , first update , then record the triple .
Print the complete trace of this loop. The value of on each line is the prefix sum from through .
Input
- The first line contains the integer .
- The second line contains exactly integers .
Output
Print exactly lines. Line contains , , and , where
Subtasks
Subtask 1 (20 points): , .
Subtask 2 (30 points): , .
Subtask 3 (50 points): , .
Examples
Input
5
4 -2 7 0 3
Output
0 4 4
1 -2 2
2 7 9
3 0 9
4 3 12
Explanation
Initially .
- For , , so .
- For , , so .
- For , , so .
- For , , so remains .
- For , , so .
Each line reports the current index, the current element, and the updated sum.