답안 #1103704

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1103704 2024-10-21T14:43:10 Z melody_rules Pareto (COCI17_pareto) C++17
80 / 80
69 ms 13644 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(50);
  cout<<veco.at(a).first<<endl;
  
  cout<<setprecision(50);
  cout<<veco.at(a).second<<endl;
  
  return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 504 KB Output is correct
4 Correct 2 ms 504 KB Output is correct
5 Correct 4 ms 852 KB Output is correct
6 Correct 24 ms 4692 KB Output is correct
7 Correct 49 ms 9268 KB Output is correct
8 Correct 69 ms 13644 KB Output is correct