2 条题解
-
1
冲击最小空间!
#include<bits/stdc++.h> #define endl '\n' using namespace std; const int N=1e5+5,INF=0x3f3f3f3f,MOD=1e9+7; const int dx[]={1,-1,0,0},dy[]={0,0,1,-1}; typedef long long LL; LL n,minn=INF,maxx=-INF,x,dp1,dp2; int main(){ ios::sync_with_stdio(false); cin.tie(nullptr);cout.tie(nullptr); cin>>n; for(int i=1;i<=n;i++){ cin>>x; LL a=dp1,b=dp2; dp1 = max({x,x*a,x*b}),dp2 = min({x,x*a,x*b}); maxx = max(maxx,dp1),minn = min(minn,dp2); } cout<<maxx<<endl<<minn; return 0; }
信息
- ID
- 1764
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 8
- 标签
- 递交数
- 117
- 已通过
- 15
- 上传者