답안 #638717

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
638717 2022-09-07T05:48:33 Z jamezzz Let's Win the Election (JOI22_ho_t3) C++17
10 / 100
10 ms 320 KB
#include <bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define sf scanf
#define pf printf
typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;

#define maxn 505
#define INF 1023456789

int n,k,a[maxn],b[maxn];
bool have[maxn];
vector<ii> v;
ld memo[maxn][maxn];

int main(){
	sf("%d%d",&n,&k);
	for(int i=0;i<n;++i){
		int x,y;
		sf("%d%d",&x,&y);
		if(y==-1)y=INF;
		v.push_back({x,y});
	}
	sort(v.begin(),v.end(),[](ii &a,ii &b){
		if(a.se==b.se)return a.fi>b.fi;
		else return a.se<b.se;
	});
	int num=0;
	for(int i=0;i<n;++i){
		tie(a[i],b[i])=v[i];
		if(b[i]!=INF)++num;
	}
	ld ans=INF;
	for(int ppl=0;ppl<=num;++ppl){
		ld cur=0;
		for(int i=0;i<ppl;++i){
			cur+=((ld)b[i])/((ld)i+1);
		}
		priority_queue<int,vector<int>,greater<int>> pq;
		for(int i=ppl;i<n;++i)pq.push(a[i]);
		for(int i=0;i<k-ppl;++i){
			cur+=((ld)pq.top())/((ld)ppl+1);
			pq.pop();
		}
		ans=min(ans,cur);
	}
	pf("%Lf\n",ans);
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:21:4: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |  sf("%d%d",&n,&k);
      |    ^
Main.cpp:24:5: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |   sf("%d%d",&x,&y);
      |     ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 3 ms 212 KB Output is correct
13 Correct 2 ms 212 KB Output is correct
14 Correct 2 ms 212 KB Output is correct
15 Correct 6 ms 316 KB Output is correct
16 Correct 6 ms 320 KB Output is correct
17 Correct 3 ms 212 KB Output is correct
18 Correct 8 ms 212 KB Output is correct
19 Correct 6 ms 212 KB Output is correct
20 Correct 2 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 312 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Incorrect 0 ms 212 KB Output isn't correct
10 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 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 312 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Incorrect 0 ms 212 KB Output isn't correct
10 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 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 312 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Incorrect 0 ms 212 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 10 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 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 3 ms 212 KB Output is correct
13 Correct 2 ms 212 KB Output is correct
14 Correct 2 ms 212 KB Output is correct
15 Correct 6 ms 316 KB Output is correct
16 Correct 6 ms 320 KB Output is correct
17 Correct 3 ms 212 KB Output is correct
18 Correct 8 ms 212 KB Output is correct
19 Correct 6 ms 212 KB Output is correct
20 Correct 2 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 0 ms 312 KB Output is correct
26 Correct 0 ms 212 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Incorrect 0 ms 212 KB Output isn't correct
30 Halted 0 ms 0 KB -