If the United Nations chose to intervene, they would likely attempt a peacekeeping mission - something that of course has been done many times in the past in various contexts. Peacekeepers have a number of responsibilities depending on the specific mandate of the operation, and these responsibilities can range from state-building to ensuring that basic human needs are met in a region. The UN Security Council would be the body to authorize such a mission.
The legal basis for UN peacekeeping comes from Chapters VI-VIII of the UN charter (Articles 33-54). I'd like to mention some relevant passages:
The Security Council shall determine the existence of any threat to the peace, breach of the peace, or act of aggression and shall make recommendations, or decide what measures shall be taken in accordance with Articles 41 and 42, to maintain or restore international peace and security.
Should the Security Council consider that measures provided for in Article 41 would be inadequate or have proved to be inadequate, it may take such action by air, sea, or land forces as may be necessary to maintain or restore international peace and security. Such action may include demonstrations, blockade, and other operations by air, sea, or land forces of Members of the United Nations.
Nothing in the present Charter precludes the existence of regional arrangements or agencies for dealing with such matters relating to the maintenance of international peace and security as are appropriate for regional action provided that such arrangements or agencies and their activities are consistent with the Purposes and Principles of the United Nations.
The Security Council shall, where appropriate, utilize such regional arrangements or agencies for enforcement action under its authority.
These three chapters, including these articles, are the usual ones invoked for peacekeeping, especially Chapter VI. They require that member states take action and provide the service of their military forces - and in this case, I would expect that the Security Council would require Country A to contribute, as simply walking away would likely be considered irresponsible (unless Country A was for some reason not a member of the UN, or if its initial occupation was deemed illegal). The UN mandate for each peacekeeping mission may extend beyond the use of military force, however, and can include, as the UN puts it,
Security sector reform and other rule of law-related activities
Support for the restoration and extension of State authority
Promotion of social and economic recovery and development
You could argue that regional occupation by Peacekeepers would be based on those principles. In a case of lawlessness or unclear governmental administration, UN occupation might be necessary for the promotion of state-building. The following Peacekeeper missions are examples of similar measures taken:
These could be interpreted to establish something of a precedent for the action you're talking about . . . but I'm not an expert in international law.
I'm looking at some official peacekeeping principles and guidelines, and some key concepts pop out. First, the parties affected by the mission must consent to the deployment and activities, which could pose a problem if whoever is in charge of Country A doesn't like the use of Peacekeepers. That said, from what you're describing, it appears that warlords are in control there, if anyone is at all, which would probably provide a loophole and allow acting without consulting them.
It's also noted that if regional authorities are weak, it may be necessary for Peacekeepers to take over parts of local administration for the purposes of a successful mission, and in the case of rampant chaos or civil war, this could be true. Of course, the behavior of Peacekeepers and the power structure of the mission as a whole need to win over the locals for it to be remotely a success, so there's going to have to be some sort of input from or at least dialogue with the community. Remember, Peacekeepers engage in state-building and restorative action, not merely custodianship.