This is likely House of Stairs by William Sleator. Although it was a short novel released in 1974, your description matches really closely.
Here's a blurb from Wikipedia:
Set in a dystopian America in the near future, the story tells of the experiences of five 16-year-olds who were living in orphanages who wake up to find themselves in a strange building that has no walls, no ceiling, and no floor: nothing but endless flights of stairs leading in every direction, seemingly infinite, so that it is impossible to get one's bearings or have perspective. On one landing is a basin of running water that serves as a toilet, sink and drinking fountain; on another, a machine with lights that intermittently produces food. The five, thrown together in these bizarre circumstances, must learn to deal with the others' disparate personalities, the lack of privacy and comfort, their clear helplessness, and a machine that only feeds them under gradually more exacting situations.
The girl sticking out her tongue (I think it's Blossom) is the first one to find the food dispenser and tries to explain to the others how it works, only to find it stops working like that. Later on it starts giving out small pellets, only if the entire group performs exactly what they were all doing when it gave off a flashing alarm and they all rushed towards it, which the group roughly terms "the dance", repeating the motion they were all in at the time.
Two of the group , Lola and Peter, eventually rebel against whatever force is holding them, and hunger strike. The entire experiment is ended once the rebels are on the brink of starving to death, and they all learn this was a military conditioning test. The three that obeyed the machine end up wandering outside, and running into a flashing stop light, immediately and helplessly begin "the dance" again.