1995A — Diagonals
1995B1 — Bouquet (Easy Version)
1995B2 — Bouquet (Hard Version)
1995C — Squaring
1995D — Cases
1995E2 — Let Me Teach You a Lesson (Hard Version)
Just explained a code. If you know the full solution, please write that in the comments below.
B1 + B2 detailed video tutorial
https://youtu.be/WIYtTD_-46k?feature=shared
Solved Problem C using dp.It was a very fun round.
static PrintWriter out = new PrintWriter(System.out); static FastReader s = new FastReader();
How to find maximal value of a * i + b * j <= K, if 0 <= i <= N, 0 <= j <= M ?
I guess, solving it less than O(N), is solution for B2 + B1
Here a+1=b, so we can do it without anything special. Let me explain how I processed each type of flower.
Do this for each type of petal a.
The implementation can be different but this is the idea which helped me solve it.
B1 can be easily solved using sliding window. But complexity will be O(nlogn) since need to sort the array.
I sorted the array and was able to solve both B1 and B2.
rainboy orz
Hi, I used mathematics to make the problem C a little simpler. Check my solution -
I am not able to understand the intuition behind it. why we reversing the square when a[i]>maxel
We are not squaring anywhere — The intuition is that for A^(2^x) to be <= than B^(2^y), given A (maximum element till now), x (the number of times we did the operation) and b (current element), we need to find y (the number of times we have to do operation for B), which turns out to be the above logarithmic equations after taking logs both side (twice).
Straight up 2 min code solving B1 is using two pointers. (Why this works?) is because the ranges is <= 1, so if all the elements were sorted then we can find the subarray of the sorted using 2 pointers.
include <bits/stdc++.h>
define INF_INT 2147483647
define what_is(x) cerr << #x << " is " << x << endl;
define all(v) v.begin(), v.end()
typedef long long ll; using namespace std;
void solve() { ll n, m; cin >> n >> m; int a[n];
}
int main(void) { ios::sync_with_stdio(false); cin.tie(nullptr);
}
Love it, thank you
for B1 using prefix sum with Binary Search worked for me, but could not apply the same to B2 :(