My solution : (https://mirror.codeforces.com/contest/1651/submission/271500008)
MY idea :
Optimal strategy is to connect the extremes of the arrays to the other network. In doing so, we may connect the extremes of both arrays to each other.
# | User | Rating |
---|---|---|
1 | tourist | 4009 |
2 | jiangly | 3823 |
3 | Benq | 3738 |
4 | Radewoosh | 3633 |
5 | jqdai0815 | 3620 |
6 | orzdevinwang | 3529 |
7 | ecnerwala | 3446 |
8 | Um_nik | 3396 |
9 | ksun48 | 3390 |
10 | gamegame | 3386 |
# | User | Contrib. |
---|---|---|
1 | cry | 167 |
2 | Um_nik | 163 |
3 | maomao90 | 162 |
3 | atcoder_official | 162 |
5 | adamant | 159 |
6 | -is-this-fft- | 158 |
7 | awoo | 157 |
8 | TheScrasse | 154 |
9 | Dominater069 | 153 |
9 | nor | 153 |
My solution : (https://mirror.codeforces.com/contest/1651/submission/271500008)
MY idea :
Optimal strategy is to connect the extremes of the arrays to the other network. In doing so, we may connect the extremes of both arrays to each other.
Given an array of infinite length having all elements as 0.
2 numbers N,K. In the next N lines , 3 integers are given : l, r, and x.
you have to add x to all the elements in the range l to r (inclusive)
Your task is to find a subsequence that satisfies all the given conditions :
Subsequence size should be maximum
Lexicographically minimum
it must form an arithmetic progression i.e [z, z + k, z + 2k, z + 3k,..., z + (l — 1)k] here z is an arbitrary number and k is given in the input (see line 2) and l is the length of the subsequence.
META DATA :
1 <= x <= 1e9;
1 <= l <= r <= 1e9;
1 <= N <= 2e5;
1 <= k <= 1e9;
Note that N is not the length of the array
Any kind of help will be highly appreciated, thanks
I used accumulate for calculating the sum of elements of the array(which got hacked) however simply calculating the sum via iteration gives the correct result.
Am i missing something or is there any problem with using this "accumulate" thing.
Accepted — (https://mirror.codeforces.com/contest/1985/submission/265437274) ,(https://mirror.codeforces.com/contest/1985/submission/265439252)
Hacked — (https://mirror.codeforces.com/contest/1985/submission/265303752)
update — this idea of using all the attacks at once (at 1st second) requires to calculate the sum of the array ,but this sum can overflow (long long is insufficient). Better idea is to use the ceil division in the check function like this :
tot += ((have + cool[i] — 1)/cool[i]) * attack[i]; Hacker of the above solution helped me figure this out. Thanks a lot sammyuri sir.
link to the problem -- https://www.spoj.com/problems/STPAR/
my solution -- https://pastebin.com/JCvFy7zr
I am not able to detect my mistake in the code. Any kind of help will be highly appreciated. Thanks
Name |
---|