The first position is a loss. It's a tricky ending, and your best learning tool would be to consule a tablebase such as the one on Shredderchess.com to see why.
The second position is a draw. Again, consult the tablebase if you wonder why alternatives don't work.
1 ... Rf1! (or Rf2, Rf3, Rf4)
2 Ke6
The most obvious try.
2 ... Kf8!
This is a standard drawing position in this ending. On the short side of the board, Black can hold on. 2 ... Kd8 loses to 3 Rh8+ Kc7, 4 Ke7 Re1, 5 e6 Re2, 6 Kf7 Rf2+, 7 Ke8 Re2, 8 e7 Rf2, 9 Rf8 Re2, 10 Kf7, and black can't stop the pawn from promoting.
With the given move, Black stops White from playing 3 Rf7+.
3 Rh8+
On moves such as 3 Ra7, Black plays 3 .. Re1!, and if White moves the King out from the cover of the pawn, Black checks with the Rook. Nor can White duck for safety with 4 Kd6 Rd1+, 5 Kc7 Rc1+, 7 Kd8 Re1!
3 ... Kg7
4 Rd8 Re1
5 Kd6 Rd1+
6 Ke7 Ra1!
With the Rook on the long side of the pawn, Black has just enough room to work in. Note that even 6 ... Rb1 would lose.
7 e6 Ra7+
8 Kd6 Ra6+
9 Kd7 Ra7+
10 Kc6
This is why Black needs the extra distance. If the Rook were on b7, this move would prevent check on the sixth rank, and after the Rook moves away, White can play e7, or on 10 ... Re7, 11 Kd6 wins.
10 ... Ra6+
As it is, White can't get close enough to the Rook, so he'll have to try a different way. Again, consult the tablebases, as Black can hold the position.
Black to move in these two positions. One is a draw the other is lost. Which is which and what is the defensive technique to secure the draw?