日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Educational Codeforces Round 88 D. Yet Another Yet Another Task(巧枚举)

發布時間:2023/12/3 编程问答 30 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Educational Codeforces Round 88 D. Yet Another Yet Another Task(巧枚举) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

cf地址

**題目大意:**一個序列,你可以選擇一個子段,要求去掉子段最大值后的和最大,求出這個最大值

**思路:**a[i]的范圍比較小,可以通過枚舉最大值,再找到最大值可以輻射的區間。經典套路了。
代碼:

#include <cstdio> #include <cstring> #include <string> #include <cmath> #include <iostream> #include <algorithm> #include <queue> #include <cstdlib> #include <stack> #include <vector> #include <set> #include <map> #include <bitset> #define INF 0x3f3f3f3f3f3f3f3f #define inf 0x3f3f3f3f #define FILL(a,b) (memset(a,b,sizeof(a))) #define re register #define lson rt<<1 #define rson rt<<1|1 #define lowbit(a) ((a)&-(a)) #define ios std::ios::sync_with_stdio(false);std::cin.tie(0);std::cout.tie(0); #define fi first #define rep(i,n) for(int i=0;(i)<(n);i++) #define rep1(i,n) for(int i=1;(i)<=(n);i++) #define se secondusing namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair<int,int > pii; const ll mod=10001; const ll N =2e5+10; const double eps = 1e-4; const double pi=acos(-1); ll gcd(int a,int b){return !b?a:gcd(b,a%b);} int dx[4]={-1,0,1,0} , dy[4] = {0,1,0,-1}; int a[N];void solve() {int n;cin>>n;rep1(i,n) cin>>a[i];int any=0;for(int i=1;i<=30;i++){int cnt=0;int x=0;for(int j=1;j<=n;j++){if(a[j]>i){cnt=0;x=0;continue;}if(a[j]==i) x=1;cnt+=a[j];if(cnt<0){cnt=0;x=0;continue;}if(x) any=max(any,cnt-i);}}cout<<any; }int main() {iosint T;T=1;while(T--){solve();}return 0; }

總結

以上是生活随笔為你收集整理的Educational Codeforces Round 88 D. Yet Another Yet Another Task(巧枚举)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。