You train for it patiently in stages, and the body adapts, with increased hematocrit and other physiological changes, but it takes time and effort..
A sea-level based sedentary smoker who was suddenly taken to 20k would pass out, but somebody with healthy heart and lungs who has gone through the trouble to acclimatize can still function up there (one will find tasks more strenuous and difficult than at sea level, but still possible). I climb very, very slowly at those heights. I plan to climb Ama Dablam (see below) in the Himalayas this October, and will spend nearly a month in Nepal to do so, as I adjust slowly (and I will sleep in an altitude tent for several weeks before I leave California to get a head start). Here's a little bit I stole from Wikipedia that may be informative:
Altitude acclimatization is the process of adjusting to decreasing oxygen levels at higher elevations, in order to avoid altitude sickness.[SUP][14][/SUP] Once above approximately 3,000 metres (10,000 ft) – a pressure of 70 kilopascals (0.69 atm) – most climbers and high-altitude trekkers take the "climb-high, sleep-low" approach. For high-altitude climbers, a typical acclimatization regimen might be to stay a few days at a base camp, climb up to a higher camp (slowly), and then return to base camp. A subsequent climb to the higher camp then includes an overnight stay. This process is then repeated a few times, each time extending the time spent at higher altitudes to let the body adjust to the oxygen level there, a process that involves the production of additional red blood cells.[SUP][15][/SUP] Once the climber has acclimatized to a given altitude, the process is repeated with camps placed at progressively higher elevations. The rule of thumb is to ascend no more than 300 m (1,000 ft) per day to sleep. That is, one can climb from 3,000 m (9,800 ft) (70 kPa or 0.69 atm) to 4,500 m (15,000 ft) (58 kPa or 0.57 atm) in one day, but one should then descend back to 3,300 m (10,800 ft) (67.5 kPa or 0.666 atm) to sleep. This process cannot safely be rushed, and this is why climbers need to spend days (or even weeks at times) acclimatizing before attempting to climb a high peak. Simulated altitude equipment such as altitude tents provide hypoxic (reduced oxygen) air, and are designed to allow partial pre-acclimation to high altitude, reducing the total time required on the mountain itself.
Here's Ama Dablam, with the summit at 22,349 feet:
