Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void solve() throws IOException {
- int n = readInt();
- int[] a = new int[n];
- int s = 0;
- for (int i = 0; i < n; i++) {
- a[i] = readInt();
- s += a[i];
- }
- if (s % n != 0) {
- out.println("Unrecoverable configuration.");
- return;
- }
- int mid = s / n;
- int dif = 0;
- for (int i = 0; i < n; i++) {
- if (a[i] != mid) dif++;
- }
- if (dif == 0) {
- out.println("Exemplary pages.");
- return;
- }
- if (dif != 2) {
- out.println("Unrecoverable configuration.");
- return;
- }
- int from = -1, to = -1, vol = -1;
- for (int i = 0; i < n; i++) {
- if (a[i] != mid) {
- if (a[i] < mid) {
- from = i+1;
- vol = mid - a[i];
- } else {
- to = i+1;
- }
- }
- }
- out.printf("%d ml. from cup #%d to cup #%d.\n", vol, from, to);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement