답안 #733438

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
733438 2023-04-30T17:48:06 Z shoryu386 Let's Win the Election (JOI22_ho_t3) C++17
10 / 100
1476 ms 988708 KB
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define db double

#define MAX 502
db dp[MAX][MAX][MAX];
int n, k;

pair<db, db> info[MAX];

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) return 0;
	else if (idx == n) return 1000000000;
	
	if (dp[idx][colabCount][voteCount] != -1) return dp[idx][colabCount][voteCount];
	if (info[idx].second == -1) return dp[idx][colabCount][voteCount] = min(recur(idx+1, colabCount, voteCount), recur(idx+1, colabCount, voteCount+1) + info[idx].first/colabCount);
	return dp[idx][colabCount][voteCount] = min({recur(idx+1, colabCount, voteCount), recur(idx+1, colabCount, voteCount+1) + info[idx].first/colabCount, recur(idx+1, colabCount+1, voteCount+1) + info[idx].second/colabCount});
}

main(){

	cin >> n >> k;
	
	for (int x = 0; x < n; x++) cin >> info[x].first >> info[x].second;
	
	sort(info, info+n, cmp);
	

	
	for (int x = 0; x <= n; x++) for (int y = 0; y <= n+1; y++) for (int z = 0; z <= n; z++) dp[x][y][z] = -1;
	
	cout << recur(0, 1, 0);
}

Compilation message

Main.cpp:30:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   30 | main(){
      | ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 440 ms 988604 KB Output is correct
6 Correct 386 ms 988676 KB Output is correct
7 Correct 407 ms 988668 KB Output is correct
8 Correct 403 ms 988620 KB Output is correct
9 Correct 420 ms 988708 KB Output is correct
10 Correct 395 ms 988576 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 440 ms 988604 KB Output is correct
6 Correct 386 ms 988676 KB Output is correct
7 Correct 407 ms 988668 KB Output is correct
8 Correct 403 ms 988620 KB Output is correct
9 Correct 420 ms 988708 KB Output is correct
10 Correct 395 ms 988576 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1442 ms 988584 KB Output is correct
13 Correct 1140 ms 988632 KB Output is correct
14 Correct 586 ms 988620 KB Output is correct
15 Correct 1435 ms 988672 KB Output is correct
16 Correct 1090 ms 988644 KB Output is correct
17 Correct 568 ms 988636 KB Output is correct
18 Correct 1410 ms 988692 KB Output is correct
19 Correct 1028 ms 988636 KB Output is correct
20 Correct 536 ms 988636 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 596 KB Output is correct
2 Correct 1 ms 596 KB Output is correct
3 Correct 0 ms 596 KB Output is correct
4 Correct 0 ms 596 KB Output is correct
5 Correct 1 ms 596 KB Output is correct
6 Correct 1 ms 596 KB Output is correct
7 Correct 1 ms 596 KB Output is correct
8 Correct 0 ms 596 KB Output is correct
9 Incorrect 1 ms 596 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 596 KB Output is correct
2 Correct 1 ms 596 KB Output is correct
3 Correct 0 ms 596 KB Output is correct
4 Correct 0 ms 596 KB Output is correct
5 Correct 1 ms 596 KB Output is correct
6 Correct 1 ms 596 KB Output is correct
7 Correct 1 ms 596 KB Output is correct
8 Correct 0 ms 596 KB Output is correct
9 Incorrect 1 ms 596 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 596 KB Output is correct
2 Correct 1 ms 596 KB Output is correct
3 Correct 0 ms 596 KB Output is correct
4 Correct 0 ms 596 KB Output is correct
5 Correct 1 ms 596 KB Output is correct
6 Correct 1 ms 596 KB Output is correct
7 Correct 1 ms 596 KB Output is correct
8 Correct 0 ms 596 KB Output is correct
9 Incorrect 1 ms 596 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1476 ms 988628 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 440 ms 988604 KB Output is correct
6 Correct 386 ms 988676 KB Output is correct
7 Correct 407 ms 988668 KB Output is correct
8 Correct 403 ms 988620 KB Output is correct
9 Correct 420 ms 988708 KB Output is correct
10 Correct 395 ms 988576 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1442 ms 988584 KB Output is correct
13 Correct 1140 ms 988632 KB Output is correct
14 Correct 586 ms 988620 KB Output is correct
15 Correct 1435 ms 988672 KB Output is correct
16 Correct 1090 ms 988644 KB Output is correct
17 Correct 568 ms 988636 KB Output is correct
18 Correct 1410 ms 988692 KB Output is correct
19 Correct 1028 ms 988636 KB Output is correct
20 Correct 536 ms 988636 KB Output is correct
21 Correct 1 ms 596 KB Output is correct
22 Correct 1 ms 596 KB Output is correct
23 Correct 0 ms 596 KB Output is correct
24 Correct 0 ms 596 KB Output is correct
25 Correct 1 ms 596 KB Output is correct
26 Correct 1 ms 596 KB Output is correct
27 Correct 1 ms 596 KB Output is correct
28 Correct 0 ms 596 KB Output is correct
29 Incorrect 1 ms 596 KB Output isn't correct
30 Halted 0 ms 0 KB -