### Bayan's blog

By Bayan, 5 years ago, ,

Hey everyone, I am a regular codeforces user just like most of you, and during the long holiday, I've decided to create a video game due to lack of contests and just overall free time. The video game is a 2D platformer like your regular Super Mario Bros. or Braid, however this time you're not saving a princess in another castle, this time you're trying to get an Accepted for a problem that you've been solving for a lots of time. You're playing as your own code and your main task is to avoid all Wrong Answers using all kinds of environment that comes into your nonexistent hands.

The game is currently in development and I've finished the first three levels. If you will find any kinds of bugs or having any ideas about next levels, please leave feedback in your comments. I'll be happy to read any of it!

P.S. There are also a buncha secrets here and there, will you find them all?
UPD1: fixed bug that baklazan found and changed the text when you die by falling.
UPD2: added 4 and 5 levels, fixed some bugs and changed background music.
4 level:

5 level:
I decided to design it in 3d

• +132

By Bayan, 5 years ago, translation, ,

Problem:
Given N cards, on both sides of each card is written one number. If you put a card on the table face up, you can not see the number written on the other side.
There are N cards on the table, let Ai be the number written on one side of the card i, a Bi be the number written on the other side of the map i. Cards are initially in a position that can be seen the number Ai.
Given K operations, for each j operation from 1 to K do the following: all cards with visible number less or equal to Tj are upended.
The result is the sum of the numbers that are visible on the cards after this operations.
1<=N,K<=200 000
1<=Ai,Bi,Tj<=1 000 000 000

Sample test:

    Input:
5 3 // N and K
4 6 // each N lines contains the numbers on the sides of the cards, Ai and Bi
9 1
8 8
4 2
3 7
8   // each K lines contain Tj
2
9
Output:
18