Codeforces Round#229 DIV2 A,B,C,D(一)

2014-11-24 08:55:38 · 作者: · 浏览: 0


这次的CF很简单,区分度不大。。。

A太水了,两个set搞定。。。B太水了没印象。。。C k比较小,可以预处理一遍。。。 D 把格子按i+j排序,选最小的k个就是目标位置。。。倒着输出。。。

A. Inna and Alarm Clock time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output

Inna loves sleeping very much, so she needs n alarm clocks in total to wake up. Let's suppose that Inna's room is a 100 × 100 square with the lower left corner at point (0, 0) and with the upper right corner at point (100, 100). Then the alarm clocks are points with integer coordinates in this square.

The morning has come. All n alarm clocks in Inna's room are ringing, so Inna wants to turn them off. For that Inna has come up with an amusing game:

  • First Inna chooses a type of segments that she will use throughout the game. The segments can be either vertical or horizontal.
  • Then Inna makes multiple moves. In a single move, Inna can paint a segment of any length on the plane, she chooses its type at the beginning of the game (either vertical or horizontal), then all alarm clocks that are on this segment switch off. The game ends when all the alarm clocks are switched off.

    Inna is very sleepy, so she wants to get through the alarm clocks as soon as possible. Help her, find the minimum number of moves in the game that she needs to turn off all the alarm clocks!

    Input

    The first line of the input contains integer n (1 ≤ n ≤ 105) ― the number of the alarm clocks. The next n lines describe the clocks: the i-th line contains two integers xi, yi ― the coordinates of the i-th alarm clock (0 ≤ xi, yi ≤ 100).

    Note that a single point in the room can contain any number of alarm clocks and the alarm clocks can lie on the sides of the square that represents the room.

    Output

    In a single line print a single integer ― the minimum number of segments Inna will have to draw if she acts optimally.

    Sample test(s) input
    4
    0 0
    0 1
    0 2
    1 0
    
    output
    2
    
    input
    4
    0 0
    0 1
    1 0
    1 1
    
    output
    2
    
    input
    4
    1 1
    1 2
    2 3
    3 3
    
    output
    3
    
    Note

    In the first sample, Inna first chooses type "vertical segments", and then she makes segments with ends at : (0, 0), (0, 2); and, for example, (1, 0), (1, 1). If she paints horizontal segments, she will need at least 3 segments.

    In the third sample it is important to note that Inna doesn't have the right to change the type of the segments during the game. That's why she will need 3 horizontal or 3 vertical segments to end the game.


    #include 
        
         
    #include 
         
           #include 
          
            #include 
           
             #include 
            
              using namespace std; set
             
               Heng,Shu; int main() { int N,a,b; scanf("%d",&N); for(int i=0;i
              
               

    B. Inna, Dima and Song time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output

    Inna is a great piano player and Dima is a modest guitar player. Dima has recently written a song and they want to play it together. Of course, Sereja wants to listen to the song very much.

    A song is a sequence of notes. Dima and Inna want to play each note at the same time. At that, they can play the i-th note at volume v(1 ≤ vai; v is an integer) both on the piano and the guitar. They should retain harmony, so the total volume with which the i-th note was played on the guitar and the piano must equal bi. If Dima and Inna cannot play a note by the described rules, they skip it and Sereja's joy drops by 1. But if Inna and Dima play the i-th note at volumes xi and yi (xi + yi = bi) correspondingly, Sereja's joy rises byxi yi.

    Sereja has just returned home from the university and his current joy is 0. Help Dima and Inna play the song so as to maximize Sereja's total joy after listening to the whole song!

    Input

    The first line of the input contains integ