# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
596234 | 2022-07-14T13:49:46 Z | hail | Pareto (COCI17_pareto) | C++17 | 45 ms | 4160 KB |
#include <bits/stdc++.h> using namespace std; using ll=long long; int main() { ios::sync_with_stdio(0); cin.tie(0); int n; cin>>n; vector<ll> money_arr(n); cout<<setprecision(20); long long total_money{}; for(int i=0; i<n; i++) { cin>>money_arr[i]; total_money+=money_arr[i]; } double perc_ppl; double perc_money; double ppl; double money; double max_d{}; double money_sum{}; sort(money_arr.rbegin(), money_arr.rend()); for(int i=1; i<=n; i++) { money_sum+=money_arr[i-1]; perc_ppl = (i/((double)n)); perc_money = money_sum/((double)total_money); if(abs(perc_money-perc_ppl)>max_d) { max_d = abs(perc_money-perc_ppl); money = perc_money; ppl = perc_ppl; } } cout<<(ppl*100)<<"\n"<<(money*100); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 324 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Correct | 3 ms | 588 KB | Output is correct |
6 | Correct | 16 ms | 1492 KB | Output is correct |
7 | Correct | 33 ms | 3028 KB | Output is correct |
8 | Correct | 45 ms | 4160 KB | Output is correct |