**2016 AIO(Intermediate) 赛题**

**Magic Squares**

**Time Limit:** 1 second

**Memory Limit:** 1 GB

**Input File:** `magicin.txt`

**Output File:** `magicout.txt`

The summer holidays have just started, but before you can go outside and play, you have to finish all of your maths homework. Your maths teacher insists that you fill out a very specific type of Magic Square. In particular:

- These magic squares are three by three grids, where each cell contains a single integer.
- Every row and column must sum to the same number (note that the two diagonals do not have to add up to the same number).

Three cells of the magic square have already been filled: the top-left cell, the top-middle cell, and the middle-left cell. You may fill in the remaining squares with any numbers you wish, though your maths teacher prefers some numbers over other numbers. These numbers are explained in the `Subtasks & Constraints' section. You pull out your trusty laptop and get to work!

### Input

The first and only line of input will contain three integers: A, B and C.

- A is the value in the top-left cell of the magic square.
- B is the value in the top-middle cell of the magic square.
- C is the value in the middle-left cell of the magic square.

### Output

Your program must output three lines each containing three space-separated integers giving the magic square.

**Farmer Drama**

**Input File:** `farmin.txt`

**Output File:** `farmout.txt`

**Time Limit:** 1 second

**Memory Limit:** 1 GB

Anna and Bob have purchased a farm in order to train for the Annual International Olympiad for Cows (AIOC). Anna's house is on the left side of the farm, and Bob's is on the right. The farm is currently divided into N plots of land of varying width by N-1 parallel fences.

However, Anna and Bob are displeased with this arrangement and each want their side of the farm to be identical to the other's to ensure fair training conditions. To resolve this situation, they agree to knock down some of the fences so that each plot is the same size as the corresponding plot on the opposite side; that is, the leftmost is the same size as the rightmost, the second leftmost the same size as the second rightmost, and so on. They begrudgingly agree that if this results in a plot in the exact middle of the farm, they will share it.

As knocking down fences is a time-consuming process, and Anna and Bob have difficulty getting along, you, an expert in the field, have been called in to determine the minimum number of fences that need to be knocked down in order to make Anna and Bob happy.

### Input

The first line of input will contain a single integer N: the number of plots into which the farm is currently divided.

The second line will contain N space-separated integers, the ith integer w_{i} representing the initial width of the ith plot on the farm.

### Output

Your program must output a single integer: the minimum number of fences you will need to knock down in order to satisfy Anna and Bob's demands. It is always possible to do so since a farm with all fences removed gives a single plot for Anna and Bob to share.

**Sculpture II**

**Input File:** `artin.txt`

**Output File:** `artout.txt`

**Time Limit:** 1 second

**Memory Limit:** 1 GB

Following your domination of the fruit sculpture market you've decided to try something new. After hours of thought you've realised the future of art will definitely be BLOCKO, specifically mass produced BLOCKO sculptures.

You've already built the assembly line which consists of a chute at a fixed position dropping BLOCKO blocks onto a conveyor belt below it. The conveyor belt moves right 1 centimetre each second. A sculpture consists of N blocks of BLOCKO, the ith of which will drop t_{i} seconds after assembly begins, have width w_{i} centimetres and height h_{i} centimetres. When a BLOCKO block is dropped it will fall straight down until its bottom edge hits either the conveyor belt or a previously placed BLOCKO block, where it immediately attaches itself to the sculpture. Note that a falling block will not stop moving if it just touches corners with another block. Furthermore when each block is dropped, its right edge will be in line with the right edge of the chute and you may assume it falls into place instantly.

For instance, consider the sculpture consisting of the following 4 blocks. The first block falls after 1 second, is 2 centimetres tall, and 3 centimetres wide.

The second block falls after 2 seconds, is 1 centimetre tall, and 2 centimetres wide.

The third block falls after 3 seconds, is 1 centimetre tall, and 2 centimetres wide.

The final block falls after 5 seconds, is 3 centimetres tall, and 1 centimetre wide. Thus the final sculpture will be:

Before you can start shipping your art across the world you must first package it. Specifically you need to determine the maximum height any part of the sculpture will be so that you can order boxes of the correct size. In the above example the sculpture's height is 4 centimetres.

### Input

The first line of input will contain a single integer N: the number of blocks in the sculpture.

N lines will follow, the ith of which will contain the integers t_{i}, w_{i}, and h_{i} describing the ith block. You may assume that the blocks will be listed in increasing order of time they are placed, that is t_{1} < t_{2} < < t_{N}.

### Output

Your program must output a single integer: the height of the sculpture in centimetres.