提交时间:2023-11-18 08:51:46
运行 ID: 110988
//c #include<bits/stdc++.h> using namespace std; struct rst { int id,mon; }za[19700]; bool cmp1(rst x,rst y)//钱数从大到小 { return x.mon>y.mon; } bool cmp2(rst x,rst y)//序号从小到大 { return x.id<y.id; } int main() { int n; cin>>n; for(int i=1;i<=n;i++) { cin>>za[i].mon; za[i].id=i; } sort(za,za+n,cmp1); int day=za[0].id; sort(za,za+n,cmp2); int ru=za[day].mon;// sort(za+day+1,za+n,cmp1);// int chu=za[day+1].mon; int q=chu-ru; if(q<=0) { cout<<0; } else { cout<<q; } return 0; }