diff --git a/.gitignore b/.gitignore index 9c0d336..b65d4ef 100644 --- a/.gitignore +++ b/.gitignore @@ -49,3 +49,4 @@ day4/U76034/chat day4/U287193/chat day4/U461920/fixed day5/hard/hard +day5/perfect/perfect diff --git a/README.md b/README.md index 71bb89b..9333274 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,10 @@ int main(){ #### 通过异色中转 #### 环 +## Day5 +### 需要学习的点 +>区间最值 + # 排序 ## 稳定性 >隔着老远swap一般不稳定 diff --git a/day5/perfect/perfect.cpp b/day5/perfect/perfect.cpp new file mode 100644 index 0000000..5e887f0 --- /dev/null +++ b/day5/perfect/perfect.cpp @@ -0,0 +1,30 @@ +//暴力10/100points + +#include +using namespace std; + +const int MAX_N=3e5+5; +int n; +int a[MAX_N]; +int ans=INT_MIN; + +int main(){ + cin.sync_with_stdio(false); + cin.tie(0); + cin>>n; + for(int i=1;i<=n;i++){ + cin>>a[i]; + } + for(int l=1;l<=n;l++){ + for(int r=l;r<=n;r++){ + int max_num=INT_MIN; + int min_num=INT_MAX; + for(int i=l;i<=r;i++){ + max_num=max(max_num,a[i]); + min_num=min(min_num,a[i]); + } + ans=max(ans,max_num^min_num); + } + } + cout<