publicstaticvoidsolve() { intx= io.nextInt(), y = io.nextInt(), n = io.nextInt(); intz= (1 + n - 1) * (n - 1) / 2; if (z > y - x) { io.println(-1); return; } io.print(x + " "); intd= x + y - x - z; for (inti= n - 1; i >= 1; i--) { d += i; io.print(d + " "); } io.println(); }
publicstaticvoidsolve() { intn= io.nextInt(), m = io.nextInt(), d = io.nextInt(); int[] a = newint[n]; for (inti=0; i < n; i++) a[i] = io.nextInt(); PriorityQueue<Integer> q = newPriorityQueue<>(); longsum=0L, ans = 0L; for (inti=0; i < n; i++) { if (a[i] <= 0) continue; q.offer(a[i]); sum += a[i]; if (q.size() > m) sum -= q.poll(); ans = Math.max(ans, sum - (long) d * (i + 1)); } io.println(ans); }
publicstaticvoidsolve() { intm= io.nextInt(), k = io.nextInt(), a1 = io.nextInt(), ak = io.nextInt(); intans= Math.max(0, m % k - a1) + Math.max(0, m / k - ak - Math.max(0, a1 - m % k) / k); io.println(ans); }