답안 #82680

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
82680 2018-11-01T10:18:25 Z heon Pareto (COCI17_pareto) C++11
30 / 80
77 ms 1688 KB
#include<bits/stdc++.h>

using namespace std;

int main(){
	int n;
	scanf("%d", &n);
	vector <int> v(n);
	int sum = 0;
	for(int i = 0; i < n; i++){
		scanf("%d", &v[i]);
		sum += v[i];
	}
	sort(v.rbegin(), v.rend());
	int curr = 0;
	double a, b;
	double mx = -1.0, solb, sola;
	for(int i = 0; i < n; i++){
		curr += v[i];
		a = (double) (i+1) / n * 100.0;
		b = (double) curr / sum * 100.0;
		if(b - a > mx){
			solb = b, sola = a;
			mx = b - a;
		}
	}
	cout << fixed << setprecision(15) << sola << "\n";
	cout << fixed << setprecision(15) << solb;
}

Compilation message

pareto.cpp: In function 'int main()':
pareto.cpp:7:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
  ~~~~~^~~~~~~~~~
pareto.cpp:11:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &v[i]);
   ~~~~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 372 KB Output is correct
3 Correct 2 ms 372 KB Output is correct
4 Incorrect 2 ms 372 KB Output isn't correct
5 Incorrect 4 ms 408 KB Output isn't correct
6 Incorrect 24 ms 840 KB Output isn't correct
7 Incorrect 49 ms 1224 KB Output isn't correct
8 Incorrect 77 ms 1688 KB Output isn't correct