답안 #82677

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

using namespace std;

int main(){
	
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int n;
	cin >> n;
	vector <int> v(n);
	int sum = 0;
	for(int i = 0; i < n; i++){
		cin >> v[i];
		sum += v[i];
	}
	sort(v.rbegin(), v.rend());
	int curr = 0;
	float a, b;
	float mx = -1.0, solb, sola;
	for(int i = 0; i < n; i++){
		curr += v[i];
		a = (float) (i+1) / n * 100.0;
		b = (float) curr / sum * 100.0;
		//printf("%.10f \n%.10f\n", a, b);
		if(b - a > mx){
			solb = b, sola = a;
			mx = b - a;
			//printf("%.10f\n", mx);
		}
	}
	printf("%.10f \n%.10f", sola, solb);
}

Compilation message

pareto.cpp: In function 'int main()':
pareto.cpp:33:8: warning: 'sola' may be used uninitialized in this function [-Wmaybe-uninitialized]
  printf("%.10f \n%.10f", sola, solb);
  ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pareto.cpp:33:8: warning: 'solb' may be used uninitialized in this function [-Wmaybe-uninitialized]
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 444 KB Output is correct
3 Correct 2 ms 464 KB Output is correct
4 Incorrect 2 ms 652 KB Output isn't correct
5 Incorrect 4 ms 764 KB Output isn't correct
6 Incorrect 20 ms 1672 KB Output isn't correct
7 Incorrect 62 ms 3336 KB Output isn't correct
8 Incorrect 61 ms 5336 KB Output isn't correct