답안 #624444

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
624444 2022-08-08T09:33:59 Z QwertyPi Let's Win the Election (JOI22_ho_t3) C++14
0 / 100
1 ms 212 KB
#include <bits/stdc++.h>
#define int long long
using namespace std;

const int N = 513;
int a[N], b[N], s[N];

struct Pair{
	int a, b;
	Pair() = default;
	Pair(int _a, int _b) : a(_a), b(_b){}; 
};

vector<Pair> vp;

int32_t main(){
	int n, k;
	cin >> n >> k;
	for(int i = 0; i < n; i++){
		cin >> a[i] >> b[i];
		vp.push_back({a[i], b[i] == -1 ? 1e9 : b[i]});
	}
	
	sort(vp.begin(), vp.end(), [](Pair x, Pair y){
		return x.b < y.b;
	});
	
	for(int i = 0; i < n; i++){
		s[i + 1] = s[i] + vp[i].a;
	}
	
	long double ans = 1e9;
	for(int i = 0; i <= k; i++){
		long double res = 0;
		for(int j = 0; j < i; j++){
			res += (long double) vp[j].b / (j + 1);
		}
		res += (long double) (s[k] - s[i]) / (i + 1);
		ans = min(ans, res);
	}
	cout << fixed << setprecision(15) << ans << endl;
}

Compilation message

Main.cpp: In function 'int32_t main()':
Main.cpp:21:34: warning: narrowing conversion of '((b[i] == -1) ? 1.0e+9 : (double)b[i])' from 'double' to 'long long int' [-Wnarrowing]
   21 |   vp.push_back({a[i], b[i] == -1 ? 1e9 : b[i]});
      |                       ~~~~~~~~~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 1 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 1 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 1 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -