Submission #598815

# Submission time Handle Problem Language Result Execution time Memory
598815 2022-07-19T06:04:58 Z denniskim Let's Win the Election (JOI22_ho_t3) C++17
56 / 100
1268 ms 42592 KB
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef __int128 lll;
typedef long double ld;
#define MAX 9223372036854775807LL
#define MIN -9223372036854775807LL
#define INF 0x3f3f3f3f3f3f3f3f
#define fi first
#define se second

ll n;
ll k;
pair<ll, ll> a[510];
ld ans = INF;
ll chk[510];
ld dp[110][110][110];
ld gap[510];

ld query(ll i)
{
	if(gap[i])
		return gap[i];
	
	for(ll j = 0 ; j <= n ; j++)
	{
		for(ll o = 0 ; o <= k ; o++)
		{
			for(ll oo = 0 ; oo <= i ; oo++)
				dp[j][o][oo] = 10000000;
		}
	}
	
	dp[0][0][0] = 0;
	
	for(ll j = 1 ; j <= n ; j++)
	{
		for(ll o = 0 ; o <= k ; o++)
		{
			for(ll oo = 0 ; oo <= i ; oo++)
			{
				dp[j][o][oo] = min(dp[j][o][oo], dp[j - 1][o][oo]);
				
				if(o >= 1)
					dp[j][o][oo] = min(dp[j][o][oo], dp[j - 1][o - 1][oo] + (ld)a[j].se / (ld)(i + 1));
				
				if(o >= 1 && oo >= 1)
					dp[j][o][oo] = min(dp[j][o][oo], dp[j - 1][o - 1][oo - 1] + (ld)a[j].fi / (ld)oo);
			}
		}
	}
	
	return gap[i] = dp[n][k][i];
}

int main(void)
{
	scanf("%lld", &n);
	scanf("%lld", &k);
	
	for(ll i = 1 ; i <= n ; i++)
	{
		scanf("%lld %lld", &a[i].se, &a[i].fi);
		
		if(a[i].fi == -1)
			a[i].fi = 1000000000;
	}
	
	sort(a + 1, a + 1 + n);
	
	for(ll i = 0 ; i <= k ; i++)
		ans = min(ans, query(i));
	
	printf("%.10Lf", ans);
	return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:59:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   59 |  scanf("%lld", &n);
      |  ~~~~~^~~~~~~~~~~~
Main.cpp:60:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   60 |  scanf("%lld", &k);
      |  ~~~~~^~~~~~~~~~~~
Main.cpp:64:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   64 |   scanf("%lld %lld", &a[i].se, &a[i].fi);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 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 0 ms 340 KB Output is correct
5 Runtime error 15 ms 20524 KB Execution killed with signal 11
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 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 0 ms 340 KB Output is correct
5 Runtime error 15 ms 20524 KB Execution killed with signal 11
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 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 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 0 ms 304 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 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 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 0 ms 304 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 1 ms 468 KB Output is correct
17 Correct 1 ms 724 KB Output is correct
18 Correct 1 ms 596 KB Output is correct
19 Correct 1 ms 852 KB Output is correct
20 Correct 1 ms 852 KB Output is correct
21 Correct 1 ms 852 KB Output is correct
22 Correct 2 ms 852 KB Output is correct
23 Correct 1 ms 852 KB Output is correct
24 Correct 1 ms 852 KB Output is correct
25 Correct 3 ms 1108 KB Output is correct
26 Correct 3 ms 1108 KB Output is correct
27 Correct 1 ms 852 KB Output is correct
28 Correct 1 ms 852 KB Output is correct
29 Correct 1 ms 852 KB Output is correct
30 Correct 1 ms 852 KB Output is correct
31 Correct 1 ms 852 KB Output is correct
32 Correct 1 ms 852 KB Output is correct
33 Correct 1 ms 852 KB Output is correct
34 Correct 1 ms 852 KB Output is correct
35 Correct 2 ms 852 KB Output is correct
36 Correct 1 ms 852 KB Output is correct
37 Correct 1 ms 852 KB Output is correct
38 Correct 1 ms 852 KB Output is correct
39 Correct 1 ms 852 KB Output is correct
40 Correct 1 ms 852 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 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 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 0 ms 304 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 1 ms 468 KB Output is correct
17 Correct 1 ms 724 KB Output is correct
18 Correct 1 ms 596 KB Output is correct
19 Correct 1 ms 852 KB Output is correct
20 Correct 1 ms 852 KB Output is correct
21 Correct 1 ms 852 KB Output is correct
22 Correct 2 ms 852 KB Output is correct
23 Correct 1 ms 852 KB Output is correct
24 Correct 1 ms 852 KB Output is correct
25 Correct 3 ms 1108 KB Output is correct
26 Correct 3 ms 1108 KB Output is correct
27 Correct 1 ms 852 KB Output is correct
28 Correct 1 ms 852 KB Output is correct
29 Correct 1 ms 852 KB Output is correct
30 Correct 1 ms 852 KB Output is correct
31 Correct 1 ms 852 KB Output is correct
32 Correct 1 ms 852 KB Output is correct
33 Correct 1 ms 852 KB Output is correct
34 Correct 1 ms 852 KB Output is correct
35 Correct 2 ms 852 KB Output is correct
36 Correct 1 ms 852 KB Output is correct
37 Correct 1 ms 852 KB Output is correct
38 Correct 1 ms 852 KB Output is correct
39 Correct 1 ms 852 KB Output is correct
40 Correct 1 ms 852 KB Output is correct
41 Correct 8 ms 3516 KB Output is correct
42 Correct 7 ms 3284 KB Output is correct
43 Correct 37 ms 5972 KB Output is correct
44 Correct 34 ms 6004 KB Output is correct
45 Correct 155 ms 9456 KB Output is correct
46 Correct 166 ms 9488 KB Output is correct
47 Correct 433 ms 12116 KB Output is correct
48 Correct 334 ms 12116 KB Output is correct
49 Correct 645 ms 14664 KB Output is correct
50 Correct 673 ms 14672 KB Output is correct
51 Correct 1268 ms 18308 KB Output is correct
52 Correct 1152 ms 18356 KB Output is correct
53 Correct 355 ms 12128 KB Output is correct
54 Correct 350 ms 12044 KB Output is correct
55 Correct 372 ms 12124 KB Output is correct
56 Correct 355 ms 12044 KB Output is correct
57 Correct 345 ms 12096 KB Output is correct
58 Correct 358 ms 12108 KB Output is correct
59 Correct 366 ms 12212 KB Output is correct
60 Correct 407 ms 12116 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 38 ms 42592 KB Execution killed with signal 11
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 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Runtime error 15 ms 20524 KB Execution killed with signal 11
6 Halted 0 ms 0 KB -