Submission #718646

# Submission time Handle Problem Language Result Execution time Memory
718646 2023-04-04T13:07:03 Z vinnipuh01 Let's Win the Election (JOI22_ho_t3) C++17
56 / 100
2500 ms 984764 KB
#include <iostream>
#include <bits/stdc++.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <deque>
#include <set>
#include <stack>
#include <string>
#include <map>
#include <queue>
#define int double
#define sqrt sqrtl

using namespace std;

const long long oo = 1e9;

double sum, ans = 0, mx = 0, mn = 1000000000, num, pos;


/*
    ViHHiPuh

   (( `'-""``""-'` ))
     )-__-_.._-__-(
   / --- (o _ o) --- \
   \ .-* ( .0. ) *-. /
   _'-. ,_ '=' _, .-'_
  / `;#'#'# - #'#'#;` \
 \_)) -----'#'----- ((_/
      # --------- #
  '# ------- ------ #'
  /..-'# ------- #'-.\
  _\...-\'# -- #'/-.../_
  ((____)- '#' -(____))


    cout << fixed << setprecision(6) << x;


    freopen ( "sum.in", "r", stdin )
*/

long long n, m;
pair<int, int> a[ 501 ];
int dp[ 501 ][ 501 ][ 501 ];

main () {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cin >> n >> m;
	for ( long long i = 1; i <= n; i ++ ) {
		cin >> a[ i ].second >> a[ i ].first;
		if ( a[ i ].first == -1 )
			a[ i ].first = oo;
	}
	ans = oo;
	sort( a + 1, a + n + 1 );
	for ( long long t = 0; t <= n; t ++ ) {
		for ( long long i = 0; i <= n; i ++ )
			for ( long long j = 0; j <= n; j ++ )
				dp[ t ][ i ][ j ] = oo;
		dp[ t ][ 0 ][ 0 ] = 0;
	}
	for ( long long k = 0; k <= m; k ++ ) {
		for ( long long i = 1; i <= n; i ++ ) {
			for ( long long j = 1; j <= min( i, m ); j ++ ) {
				dp[ i ][ j ][ 0 ] = min( dp[ i - 1 ][ j ][ 0 ], dp[ i - 1 ][ j - 1 ][ 0 ] + a[ i ].second / ( k + 1 ) );
				for ( long long t = 1; t <= min( j, k ); t ++ ) {
					dp[ i ][ j ][ t ] = min( dp[ i - 1 ][ j ][ t ], min( dp[ i - 1 ][ j - 1 ][ t ] + a[ i ].second / ( k + 1 ), dp[ i - 1 ][ j - 1 ][ t - 1 ] + a[ i ].first / t ) );
//					cout << i << " " << j << " " << t << " - " << dp[ i ][ j ][ t ] << "\n";
				}
			}
		}
//		cout << k << " - " << dp[ n ][ m ][ k ] << "\n";
		ans = min( ans, dp[ n ][ m ][ k ] );
	}
	cout << fixed << setprecision( 4 ) << ans;
}

Compilation message

Main.cpp:49:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   49 | main () {
      | ^~~~
# 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 1 ms 340 KB Output is correct
5 Correct 477 ms 984720 KB Output is correct
6 Correct 1159 ms 984764 KB Output is correct
7 Execution timed out 2620 ms 984668 KB Time limit exceeded
8 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 1 ms 340 KB Output is correct
5 Correct 477 ms 984720 KB Output is correct
6 Correct 1159 ms 984764 KB Output is correct
7 Execution timed out 2620 ms 984668 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 596 KB Output is correct
2 Correct 1 ms 596 KB Output is correct
3 Correct 1 ms 596 KB Output is correct
4 Correct 1 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 1 ms 596 KB Output is correct
9 Correct 1 ms 596 KB Output is correct
10 Correct 1 ms 596 KB Output is correct
11 Correct 1 ms 596 KB Output is correct
12 Correct 1 ms 596 KB Output is correct
13 Correct 1 ms 596 KB Output is correct
14 Correct 1 ms 468 KB Output is correct
15 Correct 1 ms 596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 596 KB Output is correct
2 Correct 1 ms 596 KB Output is correct
3 Correct 1 ms 596 KB Output is correct
4 Correct 1 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 1 ms 596 KB Output is correct
9 Correct 1 ms 596 KB Output is correct
10 Correct 1 ms 596 KB Output is correct
11 Correct 1 ms 596 KB Output is correct
12 Correct 1 ms 596 KB Output is correct
13 Correct 1 ms 596 KB Output is correct
14 Correct 1 ms 468 KB Output is correct
15 Correct 1 ms 596 KB Output is correct
16 Correct 2 ms 2132 KB Output is correct
17 Correct 2 ms 2132 KB Output is correct
18 Correct 1 ms 2132 KB Output is correct
19 Correct 2 ms 2124 KB Output is correct
20 Correct 1 ms 2132 KB Output is correct
21 Correct 2 ms 2124 KB Output is correct
22 Correct 2 ms 2132 KB Output is correct
23 Correct 1 ms 2124 KB Output is correct
24 Correct 1 ms 2132 KB Output is correct
25 Correct 2 ms 2132 KB Output is correct
26 Correct 2 ms 2124 KB Output is correct
27 Correct 2 ms 2132 KB Output is correct
28 Correct 1 ms 2124 KB Output is correct
29 Correct 1 ms 2132 KB Output is correct
30 Correct 1 ms 2132 KB Output is correct
31 Correct 1 ms 2132 KB Output is correct
32 Correct 2 ms 2132 KB Output is correct
33 Correct 1 ms 2124 KB Output is correct
34 Correct 1 ms 2132 KB Output is correct
35 Correct 1 ms 2120 KB Output is correct
36 Correct 1 ms 2132 KB Output is correct
37 Correct 1 ms 2124 KB Output is correct
38 Correct 1 ms 2132 KB Output is correct
39 Correct 1 ms 2132 KB Output is correct
40 Correct 1 ms 2132 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 596 KB Output is correct
2 Correct 1 ms 596 KB Output is correct
3 Correct 1 ms 596 KB Output is correct
4 Correct 1 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 1 ms 596 KB Output is correct
9 Correct 1 ms 596 KB Output is correct
10 Correct 1 ms 596 KB Output is correct
11 Correct 1 ms 596 KB Output is correct
12 Correct 1 ms 596 KB Output is correct
13 Correct 1 ms 596 KB Output is correct
14 Correct 1 ms 468 KB Output is correct
15 Correct 1 ms 596 KB Output is correct
16 Correct 2 ms 2132 KB Output is correct
17 Correct 2 ms 2132 KB Output is correct
18 Correct 1 ms 2132 KB Output is correct
19 Correct 2 ms 2124 KB Output is correct
20 Correct 1 ms 2132 KB Output is correct
21 Correct 2 ms 2124 KB Output is correct
22 Correct 2 ms 2132 KB Output is correct
23 Correct 1 ms 2124 KB Output is correct
24 Correct 1 ms 2132 KB Output is correct
25 Correct 2 ms 2132 KB Output is correct
26 Correct 2 ms 2124 KB Output is correct
27 Correct 2 ms 2132 KB Output is correct
28 Correct 1 ms 2124 KB Output is correct
29 Correct 1 ms 2132 KB Output is correct
30 Correct 1 ms 2132 KB Output is correct
31 Correct 1 ms 2132 KB Output is correct
32 Correct 2 ms 2132 KB Output is correct
33 Correct 1 ms 2124 KB Output is correct
34 Correct 1 ms 2132 KB Output is correct
35 Correct 1 ms 2120 KB Output is correct
36 Correct 1 ms 2132 KB Output is correct
37 Correct 1 ms 2124 KB Output is correct
38 Correct 1 ms 2132 KB Output is correct
39 Correct 1 ms 2132 KB Output is correct
40 Correct 1 ms 2132 KB Output is correct
41 Correct 18 ms 40728 KB Output is correct
42 Correct 20 ms 40720 KB Output is correct
43 Correct 18 ms 40648 KB Output is correct
44 Correct 18 ms 40648 KB Output is correct
45 Correct 29 ms 40660 KB Output is correct
46 Correct 23 ms 40704 KB Output is correct
47 Correct 29 ms 40664 KB Output is correct
48 Correct 28 ms 40648 KB Output is correct
49 Correct 35 ms 40660 KB Output is correct
50 Correct 35 ms 40660 KB Output is correct
51 Correct 42 ms 40708 KB Output is correct
52 Correct 43 ms 40724 KB Output is correct
53 Correct 27 ms 40712 KB Output is correct
54 Correct 30 ms 40692 KB Output is correct
55 Correct 31 ms 40672 KB Output is correct
56 Correct 30 ms 40732 KB Output is correct
57 Correct 29 ms 40660 KB Output is correct
58 Correct 32 ms 40640 KB Output is correct
59 Correct 27 ms 40660 KB Output is correct
60 Correct 29 ms 40684 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 2586 ms 984548 KB Time limit exceeded
2 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 1 ms 340 KB Output is correct
5 Correct 477 ms 984720 KB Output is correct
6 Correct 1159 ms 984764 KB Output is correct
7 Execution timed out 2620 ms 984668 KB Time limit exceeded
8 Halted 0 ms 0 KB -