2 条题解

  • 0
    @ 2025-10-8 16:54:28
    #include <bits/stdc++.h>
    using namespace std;
    struct node{double t;int p;}a[11000];
    bool cmp(node n1,node n2){if(n1.t!=n2.t)return n1.t<n2.t;else return n1.p<n2.p;}
    int main()
    {
        int n;scanf("%d",&n);
        for(int i=1;i<=n;i++)
        {
            scanf("%lf",&a[i].t);
            a[i].p=i;
        }
        sort(a+1,a+n+1,cmp);
        double ans=0;
        for(int i=1;i<=n;i++)
        {
            printf("%d ",a[i].p);
            ans+=(n-i)*a[i].t;
        }
        printf("\n");
        printf("%.2lf\n",ans/n);
        return 0;
    }
    
    • 0
      @ 2025-10-8 16:54:21
      #include<bits/stdc++.h>
      using namespace std;
      struct node{double t;int p;}a[11000];
      bool cmp(node n1,node n2){if(n1.t!=n2.t)return n1.t<n2.t;else return n1.p<n2.p;}
      int main()
      {
          int n;scanf("%d",&n);
          for(int i=1;i<=n;i++)
          {
              scanf("%lf",&a[i].t);
              a[i].p=i;
          }
          sort(a+1,a+n+1,cmp);
      	double ans=0;
          for(int i=1;i<=n;i++)
          {
              printf("%d ",a[i].p);
      		ans+=(n-i)*a[i].t;
          }
          printf("\n");
          printf("%.2lf\n",ans/n);
          return 0;
      }
      • 1

      信息

      ID
      878
      时间
      1000ms
      内存
      128MiB
      难度
      6
      标签
      递交数
      295
      已通过
      91
      上传者