简体中文
Telegram

讨论串 消息 #762

2 条消息 · –
  1. K
    import java.util.Scanner; public class BooksWithOrphans { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] arr = new int[n]; int sum = 0; for (int i = 0; i < n; i++) { arr[i] = sc.nextInt(); sum += arr[i]; } if (sum % n != 0) { System.out.println(-1); return; } int count = 0; while (true) { int min = Integer.MAX_VALUE, max = Integer.MIN_VALUE, minI = 0, maxI = 0; for (int i = 0; i < n; i++) { if (arr[i] < min) { min = arr[i]; minI = i; } if (arr[i] > max) { max = arr[i]; maxI = i; } } if (max == min) { break; } arr[maxI]--; arr[minI]++; count++; } System.out.println(count); } }

来自搜索索引的公开信息流 ChatCrawler ——“公开 Telegram 的 Google”;随着该社群被抓取而更新。 时间为 UTC。

仅限公开内容,使用 Telegram 官方 API。 关于 · 常见问题 · 索引限制 · 移除页面 · 目录 · 搜索 · 计算方法