Handle 12 analog input and output

Hello everyone, I am new to arduino .

Here is my challenge: i have12 rooms which has individual sub meter . I want to track how many units of water each room is consuming . So i want to put electric switch(220 v or 5v dc) in each room (12 room) so that anyone can press the button and get water. (INPUT) ardiuno should give me output for the respective relay (12 relays) so that whenever a switch is pressed , one relay out of 12 should be energised.

Challenge 1 : . If two user press the switch from there room at same time , then it should only process the first person who has pressed the switch

Challenge 2 : only one relay should be energised at single time . If room one has pressed the switch then it should not take command from any other room unless room 1 turn off the switch .

INPUT : 1-12 rooms (220v or 5 v dc) OUTPUT : 1-12 5v relay( only one relay should be energised at one single tme)

You have two states, idle and active. While active no further button presses are handled, only releasing the original button takes you back to idle state...

Note the Arduino won't ever see two buttons pressed simultaneously anyway, its running at MHz speeds, people do not. So long as you check one button at a time in your idle code you'll never be confused.