intmain(){ n = rd(); k = rd(); for (int i = 1; i <= n; ++i) a[i] = rd(); ll l = 0, r = 2e9; while (l < r) { ll mid = (l + r) / 2; valid(mid) ? r = mid : l = mid + 1; } ll ans = 0; for (int i = 1; i <= n; ++i) if (a[i] > l) { ans += sum(l + 1, a[i]); k -= a[i] - l; } ans += k * l; printf("%lld\n", ans); return0; }
intmain(){ scanf("%d", &n); for (int i = 1; i <= n; ++i) scanf("%d", &c[i].a); for (int i = 1; i <= n; ++i) scanf("%d", &c[i].b); sort(c + 1, c + 1 + n); int ans = 0; for (int i = 1; i <= n; ++i) { for (int v = 0; v <= c[i].a - c[i].b; ++v) ans = (ans + f[v]) % mod; for (int v = N - 1; v >= c[i].b; --v) f[v] = (f[v] + f[v - c[i].b]) % mod; } printf("%d\n", ans); return0; }
intmain(){ int n = rd(); int m = rd(); for (int i = 1; i <= m; ++i) { c[i].l = rd(); c[i].r = rd(); c[i].k = rd(); } sort(c + 1, c + 1 + m); for (int i = 1; i <= m; ++i) { int nw = calc(c[i].r) - calc(c[i].l - 1); for (int ptr = c[i].r; nw < c[i].k; --ptr) if (!vis[ptr]) { add(ptr); ++nw; vis[ptr] = 1; } } for (int i = 1; i <= n; ++i) printf("%d ", vis[i]); return0; }