1 solutions

  • -2
    @ 2025-12-3 13:05:29

    全错求调

    #include<bits/stdc++.h>
    using namespace std;
    int main()
    {
       int a[100005],n,maxx=-1000005;
       cin>>n;
       for(int i=1;i<=n;i++)
          cin>>a[i];
       sort(a,a+n);
       for(int i=1;i<=n;i++)
          if(a[i]-a[i+1]>maxx)maxx=a[i]-a[i-1];
       cout<<maxx;
       return 0;
    }
    
    • @ 2025-12-4 13:47:54

      已调

      #include<bits/stdc++.h>
      using namespace std;
      int a[10005];
      int main(){
          int n;cin>>n;
          for(int i=1;i<=n;i++) scanf("%d",&a[i]);
          int maxxxxxx=0;
          for(int i=2;i<=n;i++){
              maxxxxxx=max(maxxxxxx,a[i]-a[i-1]);
          }
          cout<<maxxxxxx;
          
          return 0;
      }
      

Information

ID
696
Time
1000ms
Memory
128MiB
Difficulty
7
Tags
# Submissions
23
Accepted
8
Uploaded By