Submission #137094

# Submission time Handle Problem Language Result Execution time Memory
137094 2019-07-27T05:15:56 Z KLPP Pareto (COCI17_pareto) C++14
80 / 80
71 ms 6652 KB
#include<bits/stdc++.h>

using namespace std;
typedef long long int lld;
#define rep(i,a,b) for(int i=a;i<b;i++)

int main(){
  cout<<setprecision(10);
  int n;
  scanf("%d",&n);
  lld arr[n];
  lld sum=0;
  rep(i,0,n){
    scanf("%lld",&arr[i]);
    sum+=arr[i];
  }
  sort(arr,arr+n);
  reverse(arr,arr+n);
  lld par[n+1];
  par[0]=0;
  rep(i,1,n+1){
    par[i]=arr[i-1]+par[i-1];
  }
  pair<lld,int> MD=pair<lld,int>(0,0);
  rep(i,0,n+1){
    MD=max(MD,pair<lld,int>(par[i]*n-sum*i,i));
  }
  cout<<(double)(100*MD.second)/n<<endl<<(double)(100*par[MD.second])/sum<<endl;
  //cout<<ans<<endl;
  return 0;
}

Compilation message

pareto.cpp: In function 'int main()':
pareto.cpp:10:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&n);
   ~~~~~^~~~~~~~~
pareto.cpp:14:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld",&arr[i]);
     ~~~~~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 400 KB Output is correct
5 Correct 5 ms 504 KB Output is correct
6 Correct 24 ms 2296 KB Output is correct
7 Correct 50 ms 4728 KB Output is correct
8 Correct 71 ms 6652 KB Output is correct