codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

257B.md (2052B)


      1 Source: https://codeforces.com/problemset/problem/257/B
      2 
      3 B. Playing Cubes
      4 
      5 time limit per test
      6 
      7 2 seconds
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 stdin
     16 
     17 output
     18 
     19 stdout
     20 
     21 Petya and Vasya decided to play a little. They found *n* red cubes and *m* blue cubes. The game goes like that: the players take turns to choose a cube of some color (red or blue) and put it in a line from left to right (overall the line will have *n* + *m* cubes). Petya moves first. Petya's task is to get as many pairs of neighbouring cubes of the same color as possible. Vasya's task is to get as many pairs of neighbouring cubes of different colors as possible.
     22 
     23 The number of Petya's points in the game is the number of pairs of neighboring cubes of the same color in the line, the number of Vasya's points in the game is the number of neighbouring cubes of the different color in the line. Your task is to calculate the score at the end of the game (Petya's and Vasya's points, correspondingly), if both boys are playing optimally well. To "play optimally well" first of all means to maximize the number of one's points, and second — to minimize the number of the opponent's points.
     24 
     25 Input
     26 
     27 The only line contains two space-separated integers *n* and *m* (1 ≤ *n*, *m* ≤ 105) — the number of red and blue cubes, correspondingly.
     28 
     29 Output
     30 
     31 On a single line print two space-separated integers — the number of Petya's and Vasya's points correspondingly provided that both players play optimally well.
     32 
     33 Examples
     34 
     35 Input
     36 
     37 ```
     38 3 1
     39 ```
     40 
     41 Output
     42 
     43 ```
     44 2 1
     45 ```
     46 
     47 Input
     48 
     49 ```
     50 2 4
     51 ```
     52 
     53 Output
     54 
     55 ```
     56 3 2
     57 ```
     58 
     59 Note
     60 
     61 In the first test sample the optimal strategy for Petya is to put the blue cube in the line. After that there will be only red cubes left, so by the end of the game the line of cubes from left to right will look as [blue, red, red, red]. So, Petya gets 2 points and Vasya gets 1 point.
     62 
     63 If Petya would choose the red cube during his first move, then, provided that both boys play optimally well, Petya would get 1 point and Vasya would get 2 points.