Given a set of numbers ($N<100$), select part or all of them, and ask what is the maximum value when it and $sum%10$ are not $0$.
Calculate the sum first to see if the conditions are met, and output it directly if the conditions are met. If the conditions are not met, the numbers removed will be enumerated.
int n; int val[maxn]; voidsolve() { sa(n); int ans=0; repp(i,1,n) { sa(val[i]); ans+=val[i]; } int maxx=0; if(ans%10) { printf("%d\n", ans); return; } repp(i,1,n) { int sum=ans-val[i]; if(sum%10)maxx=max(maxx,sum); } printf("%d\n", maxx); }
D - Widespread
There are a group of monsters ($N<10^5$), each monster has its own blood volume $h_i$. You now have an attack method: select one of the monsters to cause $A$ points of damage, and the remaining monsters will cause $B$ points of damage ($B<A$). Ask how many times you need to attack at least to make the health of these monsters become $0$ or negative.
Number of two-point attacks. Because $A>B$, the blood volume of $B*x$ is subtracted from each monster each time. The remaining damage is equivalent to $A-B$ damage caused by each attack. See if it can be completed in $x$ attacks.
Given a set of numbers ($N<2*10^5$), there are a total of $\frac{N*(N+1)}{2}$ consecutive subsequences. Ask how many of these subsequences have an average value greater than the given $K$.
Subtract $K$ from each element in the array, and you will find that what is left is the classic reverse order problem.
ll num[maxn]; intlowbit(int x) { return x&(-x); } ll getsum(ll x) { ll ans = 0; while (x>0) { ans += num[x]; x -= lowbit(x); } return ans; } ll add(int x, int v) { int up = maxn - 1; while (x <= up) { num[x] += v; x += lowbit(x); } return x; } ll n, k; ll val[maxn], sum[maxn]; ll stmp[maxn], s[maxn]; voidsolve() { scanf("%lld%lld", &n, &k); repp(i, 1, n) { scanf("%lld", &val[i]); val[i] -= k; sum[i] = sum[i - 1] + val[i]; stmp[i] = sum[i]; } sort(stmp + 1, stmp + n + 1); repp(i, 1, n) { s[i] = lower_bound(stmp + 1, stmp + n + 1, sum[i]) - stmp; } ll ans = 0; repp(i, 1, n) { if (sum[i] >= 0)ans++; ans += (getsum(s[i])); add(s[i], 1); } printf("%lld\n", ans); }
F - Mirrored
The meaning of the question is $N$, and its reverse order $rev(N)$, and then it is given $D$. Ask how many $N$ satisfy $rev(N)=N+D$.
I had a long discussion with Firefly. . . Considering each value bit by bit, it seems difficult to express it in detail. I feel like this is a very pure idea question. . .