답안 #733699

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
733699 2023-05-01T08:14:13 Z shoryu386 Let's Win the Election (JOI22_ho_t3) C++17
56 / 100
868 ms 36460 KB
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define db long double

#define MAX 102
db dp[MAX][MAX][MAX];
int n, k;
 
pair<db, db> info[MAX];

vector<pair<db, db>> cringe;

int maxcolab;
 
bool cmp(pair<db, db> a, pair<db, db> b){
	if (a.second == -1) a.second = 1000000000;
	if (b.second == -1) b.second = 1000000000;
	
	return a.second < b.second;
	
}
 
db recur(int idx, int colabCount, int voteCount){
	if (idx == n && voteCount >= k && maxcolab == colabCount) return 0;
	else if (idx == n) return 1000000000;
	
	if (dp[idx][colabCount][voteCount] != -1) return dp[idx][colabCount][voteCount];
	if (cringe[idx].second == -1) return dp[idx][colabCount][voteCount] = min(recur(idx+1, colabCount, voteCount), recur(idx+1, colabCount, voteCount+1) + cringe[idx].first/maxcolab);
	return dp[idx][colabCount][voteCount] = min({recur(idx+1, colabCount, voteCount), recur(idx+1, colabCount, voteCount+1) + cringe[idx].first/maxcolab, recur(idx+1, colabCount+1, voteCount+1) + cringe[idx].second/colabCount});
}

bool anticmp(pair<db, db> a, pair<db, db> b){
	if (a.second == -1) a.second = -1000000000;
	if (b.second == -1) b.second = -1000000000;
	
	return a.second > b.second;
	
}

signed main(){

	cin >> n >> k;
	
	for (int x = 0; x < n; x++) cin >> info[x].first >> info[x].second;
	
	db ans = 1000000000000000LL;
	for (int x = 1; x <= n+1; x++){
		
		//make use of x colabs
		//initial sort is optimal for 0 colabs
		
		vector<pair<db, db>> colabSect;
		vector<pair<db, db>> voteSect;
		
		//wait is dp even needed
		
		for (int y = 0; y < n; y++) voteSect.push_back(info[y]);
		
		sort(voteSect.begin(), voteSect.end(), cmp); //give cheapest

		cringe.clear();
		for (auto y : voteSect) cringe.push_back(y);
		
		
		for (int a = 0; a <= n; a++) for (int y = 0; y <= n+1; y++) for (int z = 0; z <= n; z++) dp[a][y][z] = -1;
		maxcolab = x;
		ans = min(ans, recur(0, 1, 0));
	}
	cout << std::setprecision(9) << ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Runtime error 311 ms 36424 KB Execution killed with signal 11
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Runtime error 311 ms 36424 KB Execution killed with signal 11
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 2 ms 1108 KB Output is correct
17 Correct 2 ms 1108 KB Output is correct
18 Correct 2 ms 1108 KB Output is correct
19 Correct 2 ms 1108 KB Output is correct
20 Correct 2 ms 1108 KB Output is correct
21 Correct 2 ms 1076 KB Output is correct
22 Correct 2 ms 1108 KB Output is correct
23 Correct 2 ms 1108 KB Output is correct
24 Correct 2 ms 1108 KB Output is correct
25 Correct 2 ms 1076 KB Output is correct
26 Correct 2 ms 1108 KB Output is correct
27 Correct 2 ms 1108 KB Output is correct
28 Correct 2 ms 1108 KB Output is correct
29 Correct 2 ms 1108 KB Output is correct
30 Correct 2 ms 1076 KB Output is correct
31 Correct 3 ms 1124 KB Output is correct
32 Correct 2 ms 1108 KB Output is correct
33 Correct 2 ms 1108 KB Output is correct
34 Correct 3 ms 1108 KB Output is correct
35 Correct 2 ms 1108 KB Output is correct
36 Correct 2 ms 1108 KB Output is correct
37 Correct 2 ms 1080 KB Output is correct
38 Correct 2 ms 1156 KB Output is correct
39 Correct 2 ms 1068 KB Output is correct
40 Correct 2 ms 1108 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 2 ms 1108 KB Output is correct
17 Correct 2 ms 1108 KB Output is correct
18 Correct 2 ms 1108 KB Output is correct
19 Correct 2 ms 1108 KB Output is correct
20 Correct 2 ms 1108 KB Output is correct
21 Correct 2 ms 1076 KB Output is correct
22 Correct 2 ms 1108 KB Output is correct
23 Correct 2 ms 1108 KB Output is correct
24 Correct 2 ms 1108 KB Output is correct
25 Correct 2 ms 1076 KB Output is correct
26 Correct 2 ms 1108 KB Output is correct
27 Correct 2 ms 1108 KB Output is correct
28 Correct 2 ms 1108 KB Output is correct
29 Correct 2 ms 1108 KB Output is correct
30 Correct 2 ms 1076 KB Output is correct
31 Correct 3 ms 1124 KB Output is correct
32 Correct 2 ms 1108 KB Output is correct
33 Correct 2 ms 1108 KB Output is correct
34 Correct 3 ms 1108 KB Output is correct
35 Correct 2 ms 1108 KB Output is correct
36 Correct 2 ms 1108 KB Output is correct
37 Correct 2 ms 1080 KB Output is correct
38 Correct 2 ms 1156 KB Output is correct
39 Correct 2 ms 1068 KB Output is correct
40 Correct 2 ms 1108 KB Output is correct
41 Correct 741 ms 16760 KB Output is correct
42 Correct 757 ms 16760 KB Output is correct
43 Correct 866 ms 16756 KB Output is correct
44 Correct 709 ms 16844 KB Output is correct
45 Correct 769 ms 16760 KB Output is correct
46 Correct 697 ms 16760 KB Output is correct
47 Correct 802 ms 16760 KB Output is correct
48 Correct 726 ms 16772 KB Output is correct
49 Correct 766 ms 16756 KB Output is correct
50 Correct 684 ms 16844 KB Output is correct
51 Correct 740 ms 16760 KB Output is correct
52 Correct 698 ms 16724 KB Output is correct
53 Correct 868 ms 16760 KB Output is correct
54 Correct 743 ms 16764 KB Output is correct
55 Correct 755 ms 16764 KB Output is correct
56 Correct 767 ms 16772 KB Output is correct
57 Correct 734 ms 16764 KB Output is correct
58 Correct 751 ms 16844 KB Output is correct
59 Correct 783 ms 16768 KB Output is correct
60 Correct 838 ms 16756 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 309 ms 36460 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Runtime error 311 ms 36424 KB Execution killed with signal 11
6 Halted 0 ms 0 KB -