Submission #733445

# Submission time Handle Problem Language Result Execution time Memory
733445 2023-04-30T18:18:55 Z shoryu386 Let's Win the Election (JOI22_ho_t3) C++17
10 / 100
72 ms 356 KB
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define db long double

#define MAX 502
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;
	
}
main(){

	cin >> n >> k;
	
	for (int x = 0; x < n; x++) cin >> info[x].first >> info[x].second;
	
	db ans = 1000000000000000LL;
	for (int x = 0; x <= n; 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
		
		for (int y = 0; y < x; y++){
			colabSect.push_back(voteSect.back()); 
			
			//cout << voteSect.back().first << ' ' << voteSect.back().second << '\n';
			
			voteSect.pop_back();
			
		}
		//cout << '\n' << '\n';
		
		if (colabSect.size() != 0 && colabSect.back().second == -1) break;
		
		sort(voteSect.begin(), voteSect.end()); //return to cheapest votes
		
		int votesNeeded = k - (int)colabSect.size();
		if (votesNeeded < 0) break;
		int colabCount = 1;
		db curAns = 0;
		for (auto y : colabSect){
			curAns += y.second/colabCount; colabCount++;
		}
		
		for (int y = 0; y < votesNeeded; y++){
			curAns += voteSect[y].first/colabCount;
		}
		
		//cout << curAns << "!!!\n\n";
		ans = min(curAns, ans);
	}
	cout << std::setprecision(9) << ans;
}

Compilation message

Main.cpp:19:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   19 | main(){
      | ^~~~
# Verdict Execution time Memory 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 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
# Verdict Execution time Memory 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 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 212 KB Output is correct
12 Correct 18 ms 340 KB Output is correct
13 Correct 19 ms 340 KB Output is correct
14 Correct 11 ms 340 KB Output is correct
15 Correct 46 ms 344 KB Output is correct
16 Correct 33 ms 356 KB Output is correct
17 Correct 12 ms 340 KB Output is correct
18 Correct 60 ms 356 KB Output is correct
19 Correct 34 ms 356 KB Output is correct
20 Correct 12 ms 340 KB Output is correct
# Verdict Execution time Memory 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 1 ms 212 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 -
# Verdict Execution time Memory 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 1 ms 212 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 -
# Verdict Execution time Memory 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 1 ms 212 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 -
# Verdict Execution time Memory Grader output
1 Incorrect 72 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory 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 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 212 KB Output is correct
12 Correct 18 ms 340 KB Output is correct
13 Correct 19 ms 340 KB Output is correct
14 Correct 11 ms 340 KB Output is correct
15 Correct 46 ms 344 KB Output is correct
16 Correct 33 ms 356 KB Output is correct
17 Correct 12 ms 340 KB Output is correct
18 Correct 60 ms 356 KB Output is correct
19 Correct 34 ms 356 KB Output is correct
20 Correct 12 ms 340 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 1 ms 212 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 -