Someone helps me solve this problem please, I can't come up with any ideas to solve.
Thanks in advance.
№ | Пользователь | Рейтинг |
---|---|---|
1 | tourist | 3985 |
2 | jiangly | 3814 |
3 | jqdai0815 | 3682 |
4 | Benq | 3529 |
5 | orzdevinwang | 3526 |
6 | ksun48 | 3517 |
7 | Radewoosh | 3410 |
8 | hos.lyric | 3399 |
9 | ecnerwala | 3392 |
9 | Um_nik | 3392 |
Страны | Города | Организации | Всё → |
№ | Пользователь | Вклад |
---|---|---|
1 | cry | 169 |
2 | maomao90 | 162 |
2 | Um_nik | 162 |
4 | atcoder_official | 161 |
5 | djm03178 | 158 |
6 | -is-this-fft- | 157 |
7 | adamant | 155 |
8 | awoo | 154 |
8 | Dominater069 | 154 |
10 | luogu_official | 150 |
Someone helps me solve this problem please, I can't come up with any ideas to solve.
Thanks in advance.
Someone help me solve this problem please, I don't know how to find formula for this problem
Given two arrays a and b, both arrays have size n. Find m the length of longest subsequence of i (1 <= i1 <= i2 <= i3 <= im) such that max(a[i1],a[i2],...,a[im]) + sum(b[i1],b[i2],...,b[im]) <= S , with S is given.
Constraints : n <= 10^5 , 1 <= a[i],b[i] <= 10^9
S <= 10^18
a[i] < a[i+1] for every 1 <= i <= n-1 (array a is increasing)
Input : First line : n,S
The following n lines : a[i] b[i]
An example test: Input:
4 10
1 5
2 1
3 3
4 2
Output :
3
Explain: Chosen subsequence is (2,3,4) (1-indexed).
Given an array a consisting of n elements, call array b consisting of n elements such that (a[1] — b[1])^2 + (a[2] — b[2])^2 + ... + (a[n] — b[n])^2 is minimum and sum of all elements of array B is equal to m.
Given n, array A, m, find the value of (a[1] — b[1])^2 + (a[2] — b[2])^2 + ... + (a[n] — b[n])^2.
Constraints : 1 <= n <= 1e5 , 1 <= m <= 2e9, 1 <= a[i] <= 2e9
Input : first line n,m respectively, second line is the elements of array A Output : the expected value
Ex:
Input : 3 3 3 4 5 Output : 27 Input : 10 4 2 3 4 5 Output : 4
Название |
---|