Submission #1103705

# Submission time Handle Problem Language Result Execution time Memory
1103705 2024-10-21T14:44:05 Z melody_rules Pareto (COCI17_pareto) C++17
80 / 80
67 ms 12112 KB
#include <bits/stdc++.h>
#define int long long
#define db long double

using namespace std;

signed main() {
  int n=0;
  int a=0;
  db b=0;
  db c=0;
  db d=0;
  int i=0;
  
  cin>>n;
  vector<int> vec(n);
  vector<pair<db, db>> veco(n);
  
  for(i=0;i<n;i++) {
    cin>>a;
    vec.at(i) = a;
    
    c += a;
  }
  
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  
  a=0;
  b=0;
  
  for(i=0;i<n;i++) {
    b = (i+1);
    b *= 100;
    b /= n;
    
    veco.at(i).first = b;
  }
  
  a=0;
  b=0;
  
  for(i=0;i<n;i++) {
      b += vec.at(i);
      d = b;
      
      d *= 100;
      d /= c;
      
      veco.at(i).second = d;
  }
  
  b=0;
  
  for(i=0;i<n;i++) {
      if((veco.at(i).second - veco.at(i).first) > b) {
          b = (veco.at(i).second - veco.at(i).first);
          a = i;
      }
  }
  
  cout<<setprecision(17);
  cout<<veco.at(a).first<<endl;
  
  cout<<setprecision(17);
  cout<<veco.at(a).second<<endl;
  
  return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 4 ms 592 KB Output is correct
6 Correct 23 ms 4352 KB Output is correct
7 Correct 51 ms 8016 KB Output is correct
8 Correct 67 ms 12112 KB Output is correct