QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 256 MB Total points: 100

#22784. Maestà delle montagne

Statistics

Le mucche trascorrono l’estate vicino a Front Range nelle Rocky Mountains, non lontano dalla casa di Coach Rob. All’orizzonte si vedono $N$ montagne ($N \le 100{,}000$), per esempio (qui $N=5$):

                   /\
      /\          /  \  /\
     /  \/\    /\/    \/  \
    /    \ \  /  \    /    \
  -----------------------------

Ogni montagna è un triangolo isoscele la cui altezza è esattamente il doppio della lunghezza della base. È descritta dalle coordinate $x$ dei due estremi della base; sono interi positivi rappresentabili in 16 bit con segno. Calcola l’area totale dell’unione delle montagne.

Input

  • Riga 1: intero $N$.
  • Righe $2..N+1$: ciascuna descrive una montagna con due interi ordinati separati da spazio.

Output

Un intero, l’area dell’unione delle montagne. L’area è sempre intera e rappresentabile in 32 bit con segno.

Esempi

Input 1

5
2 7
6 9
12 15
14 21
20 25

Output 1

114

Autore del problema: Brian Dean, 2001

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.