I need a plan to improve myself in DP as i think this topic is hard to me and don't know the main idea of it and when we use DP in general.
| # | User | Rating |
|---|---|---|
| 1 | Benq | 3676 |
| 2 | Kevin114514 | 3659 |
| 3 | jiangly | 3640 |
| 4 | turmax | 3450 |
| 5 | tourist | 3408 |
| 6 | strapple | 3360 |
| 7 | Um_nik | 3354 |
| 8 | squareOf105 | 3348 |
| 9 | maroonrk | 3312 |
| 10 | idontwannadothis…e | 3191 |
| # | User | Contrib. |
|---|---|---|
| 1 | Qingyu | 154 |
| 2 | nik_exists | 151 |
| 3 | maspy | 149 |
| 4 | AmShZ | 146 |
| 5 | Um_nik | 143 |
| 6 | Errichto | 139 |
| 7 | BledDest | 136 |
| 8 | adamant | 135 |
| 9 | maroonrk | 133 |
| 10 | cry | 130 |
I need a plan to improve myself in DP as i think this topic is hard to me and don't know the main idea of it and when we use DP in general.
I will brute force in value where i will make ternary search on each value of a, b, c then take the max area. The problem is when i add value from range [0:k] to any side, This may result that the triangle isn't right.
long double f(long double a, long double b, long double c){
if((a + b) <= c || (a + c) <= b || (b + c) <= a) return NINF;
long double s = ((a + b + c) / 2);
return sqrt(s * (s - a) * (s - b) * (s - c));
}
long double ts(long double a, long double b, long double c, long double k){
long double l = 0, r = k;
long double maxVal = 0;
while(r - l > 1e-9){
long double mid = ((l + r) / 2);
if(f(a + mid, b, c) < f(a + mid + 1e-7, b, c)){
l = mid;
}else{
r = mid;
}
}
return f(a + r, b, c);
}
void solve(){
long double a, b, c, k;
read(a, b, c, k);
cout << setprecision(10) << max({ts(a, b, c, k), ts(b, a, c, k), ts(c, a, b, k)}) << "\n";
}
| Name |
|---|


