Submission #598810

# Submission time Handle Problem Language Result Execution time Memory
598810 2022-07-19T05:58:49 Z denniskim Let's Win the Election (JOI22_ho_t3) C++17
56 / 100
2062 ms 42596 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];

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++)
	{
		for(ll j = 0 ; j <= n ; j++)
		{
			for(ll o = 0 ; o <= k ; o++)
			{
				for(ll oo = 0 ; oo <= k ; 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 <= k ; 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);
					
					//printf("%.10Lf ", dp[j][o][oo]);
				}
				//printf("\n");
			}
			//printf("\n");
		}
		
		ans = min(ans, dp[n][k][i]);
	}
	
	printf("%.10Lf", ans);
	return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:22:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |  scanf("%lld", &n);
      |  ~~~~~^~~~~~~~~~~~
Main.cpp:23:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |  scanf("%lld", &k);
      |  ~~~~~^~~~~~~~~~~~
Main.cpp:27:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |   scanf("%lld %lld", &a[i].se, &a[i].fi);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 1 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 16 ms 20736 KB Execution killed with signal 11
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 1 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 16 ms 20736 KB Execution killed with signal 11
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 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 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 368 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 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 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 368 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 440 KB Output is correct
17 Correct 1 ms 724 KB Output is correct
18 Correct 1 ms 696 KB Output is correct
19 Correct 2 ms 852 KB Output is correct
20 Correct 2 ms 852 KB Output is correct
21 Correct 2 ms 852 KB Output is correct
22 Correct 3 ms 816 KB Output is correct
23 Correct 2 ms 852 KB Output is correct
24 Correct 2 ms 932 KB Output is correct
25 Correct 5 ms 1108 KB Output is correct
26 Correct 4 ms 1108 KB Output is correct
27 Correct 2 ms 816 KB Output is correct
28 Correct 2 ms 820 KB Output is correct
29 Correct 2 ms 852 KB Output is correct
30 Correct 2 ms 852 KB Output is correct
31 Correct 2 ms 852 KB Output is correct
32 Correct 2 ms 820 KB Output is correct
33 Correct 2 ms 852 KB Output is correct
34 Correct 2 ms 852 KB Output is correct
35 Correct 2 ms 852 KB Output is correct
36 Correct 2 ms 824 KB Output is correct
37 Correct 2 ms 816 KB Output is correct
38 Correct 2 ms 768 KB Output is correct
39 Correct 2 ms 852 KB Output is correct
40 Correct 2 ms 852 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 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 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 368 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 440 KB Output is correct
17 Correct 1 ms 724 KB Output is correct
18 Correct 1 ms 696 KB Output is correct
19 Correct 2 ms 852 KB Output is correct
20 Correct 2 ms 852 KB Output is correct
21 Correct 2 ms 852 KB Output is correct
22 Correct 3 ms 816 KB Output is correct
23 Correct 2 ms 852 KB Output is correct
24 Correct 2 ms 932 KB Output is correct
25 Correct 5 ms 1108 KB Output is correct
26 Correct 4 ms 1108 KB Output is correct
27 Correct 2 ms 816 KB Output is correct
28 Correct 2 ms 820 KB Output is correct
29 Correct 2 ms 852 KB Output is correct
30 Correct 2 ms 852 KB Output is correct
31 Correct 2 ms 852 KB Output is correct
32 Correct 2 ms 820 KB Output is correct
33 Correct 2 ms 852 KB Output is correct
34 Correct 2 ms 852 KB Output is correct
35 Correct 2 ms 852 KB Output is correct
36 Correct 2 ms 824 KB Output is correct
37 Correct 2 ms 816 KB Output is correct
38 Correct 2 ms 768 KB Output is correct
39 Correct 2 ms 852 KB Output is correct
40 Correct 2 ms 852 KB Output is correct
41 Correct 9 ms 3284 KB Output is correct
42 Correct 10 ms 3284 KB Output is correct
43 Correct 64 ms 5980 KB Output is correct
44 Correct 78 ms 5984 KB Output is correct
45 Correct 296 ms 9488 KB Output is correct
46 Correct 314 ms 9428 KB Output is correct
47 Correct 603 ms 12116 KB Output is correct
48 Correct 606 ms 12116 KB Output is correct
49 Correct 1129 ms 14744 KB Output is correct
50 Correct 1083 ms 14748 KB Output is correct
51 Correct 2062 ms 18248 KB Output is correct
52 Correct 2023 ms 18244 KB Output is correct
53 Correct 608 ms 12116 KB Output is correct
54 Correct 654 ms 12116 KB Output is correct
55 Correct 601 ms 12116 KB Output is correct
56 Correct 656 ms 12236 KB Output is correct
57 Correct 608 ms 12108 KB Output is correct
58 Correct 644 ms 12116 KB Output is correct
59 Correct 656 ms 12116 KB Output is correct
60 Correct 629 ms 12116 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 178 ms 42596 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 1 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 16 ms 20736 KB Execution killed with signal 11
6 Halted 0 ms 0 KB -