提交时间:2021-05-15 17:15:03
运行 ID: 19396
#include<bits/stdc++.h> using namespace std; int a[1010],r[1010]; int n,ans,tot; void init() { cin>>n>>r[1]; for(int i=1;i<=n;++i){ a[i]=r[i]%10; r[i+1]=(r[i]*6807+2831)%201701; } } int check(int x) { int max1=0,max2=0,minn; for(int i=1;i<=x-1;++i) max1=max(max1,a[i]); for(int i=x+1;i<=n;++i) max2=max(max2,a[i]); minn=min(max1,max2); if(minn>a[x])return minn-a[x]; else return 0; } int main() { init(); for(int i=2;i<=n-1;++i){ ans+=check(i); } cout<<ans; return 0; }