提交时间:2023-11-18 10:56:12
运行 ID: 111149
#include<bits/stdc++.h> using namespace std; int price[10005]; int sum[10005]; int main() { int day,max=0,m=0,ans=0,x; int min=1919810; int cnt=1; cin>>day; for(int i=1;i<=day;i++) { cin>>price[i]; sum[i]=price[i]; if(price[i]<min) { min=price[i]; x=i; } } sort(sum,sum+day+1); for(int i=x;i<=day;i++) { if(price[i]>sum[1]&&m==0) { ans=price[i]-sum[cnt]; price[x]=price[i]; m++; cnt++; } } cout<<ans<<endl; return 0; }