Log inSign up
Problems / B013

Box totals per carrier

200 ptsCases 15Set by dongbinna
Added October 30.
1 solved1 attempted1 submissionssolvers took 1.0 tries on average

Statement

At a parcel sorting center, carriers loaded with boxes pass along a belt one after another. A carrier has two decks, and boxes are loaded on the upper deck and on the lower deck. The number of boxes on the two decks differs from carrier to carrier.

A worker standing at the end of the belt writes the total number of boxes on a carrier onto a record sheet, one line each time a carrier passes. So line i of the record sheet is the number of boxes on the upper deck plus the number on the lower deck of the i-th carrier to pass. The carriers pass in the order they are given in the input, so the order of the lines on the record sheet is the same as the order of the lines of the input.

Write a program that prints the contents of the record sheet when the number of carriers that pass in a day T and the number of boxes on the two decks of each carrier are given.

One point needs care. At most 1,000,000 carriers pass in a day. Adding two numbers is light work in itself. But sending the result out separately for every carrier, one line at a time, spends all of the time on the sending alone and can go over the time limit. It is better to read the input all at once rather than line by line, and to gather the results and send them out in one go at the end.

For example, suppose T=5 carriers passed and the numbers of boxes on the two decks of each carrier are as in the following table.

Carrier number12345
Upper deck37237
Lower deck62246

What goes onto the record sheet is then as follows. Carrier 1 gives 3 + 6 = 9, carrier 3 gives 2 + 2 = 4, and carrier 5 gives 7 + 6 = 13.

Carrier number12345
Total number of boxes994713

So the record sheet comes to five lines with 9, 9, 4, 7 and 13 written one per line.

Input and output examples

Example 1

Input

5
3 6
7 2
2 2
3 4
7 6

Output

9
9
4
7
13

Example 2

Input

1
1 2

Output

3

Example 3

Input

2
7 7
2 9

Output

14
11

Input

  • First the number of carriers T is given on the first line. T is a natural number from 1 to 1,000,000.

  • Next the information for each carrier is given over T lines, in the order the carriers passed. Each line holds the number of boxes on the upper deck and the number of boxes on the lower deck, in that order, with a space between them. Both values are natural numbers from 1 to 9. No deck is left empty, so neither of the two values is ever 0.

Output

  • Print T lines. Line i holds the total number of boxes on the i-th carrier to pass.

Requirements

  • Read the input from standard input and write the answer to standard output
  • There are at most 1,000,000 carriers. Sending the results out separately, one line at a time, can go over the time limit
  • Reading the input all at once rather than line by line is faster
  • One blank line is attached after the last line.
  • Grading compares the output with the expected value down to the last character
  • You must write a program that reads from standard input and writes to standard output
  • Trailing spaces at the end of a line and blank lines at the end of the output are ignored when grading
  • The languages you can use are Python and JavaScript
  • The memory limit is 256MB. The browser does not measure it, it only states it
  • The time limit is set by measuring the setter's reference solution on the same runtime
  • On this problem you submit code, not a prompt. That code runs in the browser on this device, and all that goes to the server is a fingerprint of the output and the time it took. Whether it is correct is decided by the server. The run time is a number each device reports, so the code and the device details are posted next to it on the leaderboard.
  • There are 15 cases, and 3 of them show the input together with the expected output. The rest are used only when you submit and are not shown on this page.
  • You have to pass all 15 cases to solve this.
Read the requirements carefully before solving. Tampering with the grading to make a submission look like a pass can get you sanctioned if caught. The code you submit is published on the leaderboard along with the result.

Examples

3 public cases. Judging also uses hidden cases. You have to pass all 15 cases to solve this.

Input
Expected output
1
1 2
3
2
7 7
2 9
14
11
5
3 6
7 2
2 2
3 4
7 6
9
9
4
7
13

Solution

Your code runs on this device. Only the fingerprint of the output and the elapsed time go to the server. The server decides whether it is correct.

0 chars1 lineMemory 256MB (recorded only)Reference 275ms

Submitting requires you to log in. Running against the public cases works without one.

You can test with 3 public cases. Submitting runs the hidden cases too.

People who solved this problem

The time shown is the time spent solving. Input reading time is outside the solver's control, so it is excluded. And since each device reports this value itself, we record which device measured it.

1bampal21.95s185 charsPythonWindows NT 10.0 / Chrome/156.0.0.0 / 8코어 / 16GB

Log in and you can see the code once you solve this problem.