Heliot Ramos had three hits and drove in a run, Mason Black pitched into the sixth inning, and the San Francisco Giants topped the Kansas City Royals 2-1.