-
Notifications
You must be signed in to change notification settings - Fork 0
/
99_B.cpp
63 lines (57 loc) · 881 Bytes
/
99_B.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include<iostream>
#include<vector>
#include<algorithm>
#include<climits>
using namespace std;
int main()
{
int n;
cin>>n;
vector<int>a;
int sum = 0;
for(int i=0;i<n;i++)
{
int t;
cin>>t;
a.push_back(t);
sum += t;
}
if(sum%n != 0)
{
cout<<"Unrecoverable configuration."<<endl;
}
else
{
int m = sum/n;
int minm=INT_MAX,maxm=0;
int minIndex = 0,maxIndex=0;
int ret = 0;
for(int i=0;i<(int)a.size();i++)
{
if(a[i]!=m)
{
ret++;
if(a[i]<minm)
{
minm = min(minm,a[i]);
minIndex = i;
}
if(a[i]>maxm)
{
maxm = a[i];
maxIndex = i;
}
}
}
if(ret==0)
cout<<"Exemplary pages."<<endl;
else
{
if(ret==1 || ret>2)
cout<<"Unrecoverable configuration."<<endl;
else
cout<<m-minm<<" ml. from cup #"<<(minIndex+1)<<" to cup #"<<(maxIndex+1)<<"."<<endl;
}
}
return 0;
}