update
This commit is contained in:
parent
f2cd24bdad
commit
eb5fc7aab6
16
README.md
16
README.md
@ -45,3 +45,19 @@ void bfs(){
|
|||||||
for(ll i{0};i<max_n;i++)dp[i]=ll_min;
|
for(ll i{0};i<max_n;i++)dp[i]=ll_min;
|
||||||
dp[0]=0; // 注意第0个点是能到达的reachable
|
dp[0]=0; // 注意第0个点是能到达的reachable
|
||||||
```
|
```
|
||||||
|
#### 非最优解时注意骗分卡时间
|
||||||
|
```cpp
|
||||||
|
const ll max_coin{(ll)1e5+5};//d+g = x[n] -> g = x[n]-d我的推导是这样的,但是错了,必须将max_coin设置为1e5+5也就是s[i]最大值,注意超时问题,可以自己生成样例测试
|
||||||
|
|
||||||
|
ll l{0},r{max_coin},ans{ll_max};
|
||||||
|
while(l<=r){
|
||||||
|
ll mid{(l+r)/2};
|
||||||
|
const bool check_ret{check(mid)};
|
||||||
|
if(check_ret){
|
||||||
|
ans = mid;
|
||||||
|
r=mid-1;
|
||||||
|
}else{
|
||||||
|
l=mid+1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
@ -1,11 +1,24 @@
|
|||||||
|
#define NDEBUG
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
#include <fstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
|
||||||
|
#define NV(v)#v<<" : "<<(v)
|
||||||
|
#ifdef NDEBUG
|
||||||
|
#define DEBUG(code)
|
||||||
|
#else
|
||||||
|
#define DEBUG(code){code}
|
||||||
|
#endif
|
||||||
using ll = long long;
|
using ll = long long;
|
||||||
|
|
||||||
auto &is = std::cin;
|
|
||||||
|
#ifdef NDEBUG
|
||||||
|
auto &is = std::cin;
|
||||||
|
#else
|
||||||
|
auto is = std::ifstream("/root/dev/cpp/algorithm_2024/src/P3957/P3957_9.in");
|
||||||
|
#endif
|
||||||
auto &os = std::cout;
|
auto &os = std::cout;
|
||||||
|
|
||||||
const ll max_n = 5e5+5, ll_min{std::numeric_limits<decltype(ll_min)>::min()},
|
const ll max_n = 5e5+5, ll_min{std::numeric_limits<decltype(ll_min)>::min()},
|
||||||
@ -50,7 +63,8 @@ int main(){
|
|||||||
is>>points[i].posit>>points[i].score;
|
is>>points[i].posit>>points[i].score;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ll max_coin{points[n].posit-d};//d+g = x[n] -> g = x[n]-d
|
// const ll max_coin{(ll)1e9+5};//d+g = x[n] -> g = x[n]-d我的推导是这样的,但是错了,必须将max_coin设置为1e5+5也就是s[i]最大值,会TLE最终研究了一下应该是作者卡时间
|
||||||
|
const ll max_coin{std::min(std::max(d-1,points[n].posit-d),(ll)1e4)};//d+g = x[n] -> g = x[n]-d我的推导是这样的,但是错了,必须将max_coin设置为1e5+5也就是s[i]最大值,会TLE最终研究了一下应该是作者卡时间
|
||||||
ll l{0},r{max_coin},ans{ll_max};
|
ll l{0},r{max_coin},ans{ll_max};
|
||||||
while(l<=r){
|
while(l<=r){
|
||||||
ll mid{(l+r)/2};
|
ll mid{(l+r)/2};
|
||||||
@ -61,6 +75,9 @@ int main(){
|
|||||||
}else{
|
}else{
|
||||||
l=mid+1;
|
l=mid+1;
|
||||||
}
|
}
|
||||||
|
DEBUG(
|
||||||
|
os<<NV(l)<<"\t"<<NV(r)<<'\n';
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
os<<(ans==ll_max?-1:ans)<<'\n';
|
os<<(ans==ll_max?-1:ans)<<'\n';
|
||||||
|
500001
src/P3957/P3957_9.in
Normal file
500001
src/P3957/P3957_9.in
Normal file
File diff suppressed because it is too large
Load Diff
1
src/P3957/P3957_9.out
Normal file
1
src/P3957/P3957_9.out
Normal file
@ -0,0 +1 @@
|
|||||||
|
450
|
Loading…
Reference in New Issue
Block a user