Submission #1044539

# Submission time Handle Problem Language Result Execution time Memory
1044539 2024-08-05T10:32:25 Z pan Let's Win the Election (JOI22_ho_t3) C++17
10 / 100
529 ms 8328 KB
#include <bits/stdc++.h>
//#include "bits_stdc++.h"
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define endl '\n'
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define input(x) scanf("%lld", &x);
#define input2(x, y) scanf("%lld%lld", &x, &y);
#define input3(x, y, z) scanf("%lld%lld%lld", &x, &y, &z);
#define input4(x, y, z, a) scanf("%lld%lld%lld%lld", &x, &y, &z, &a);
#define print(x, y) printf("%lld%c", x, y);
#define show(x) cerr << #x << " is " << x << endl;
#define show2(x,y) cerr << #x << " is " << x << " " << #y << " is " << y << endl;
#define show3(x,y,z) cerr << #x << " is " << x << " " << #y << " is " << y << " " << #z << " is " << z << endl;
#define all(x) x.begin(), x.end()
#define discretize(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define FOR(i, x, n) for (ll i =x; i<=n; ++i)
#define RFOR(i, x, n) for (ll i =x; i>=n; --i) 
using namespace std;
mt19937_64 rnd(chrono::steady_clock::now().time_since_epoch().count());
//using namespace __gnu_pbds;
//#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
//#define ordered_multiset tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update>
typedef long long ll;
typedef long double ld;
typedef pair<ld, ll> pd;
typedef pair<string, ll> psl;
typedef pair<ll, ll> pi;
typedef pair<pi, ll> pii;
typedef pair<pi, pi> piii;

ld const INF = 1e13;

ll n, k;
vector<vector<ld> > prevv, dp; // dp[using city until][no.of conllaborator][count vote]
pi city[505];
int main()
{
	input2(n, k);
	for (ll i=1; i<=n; ++i)  {input2(city[i].s, city[i].f); if (city[i].f==-1) city[i].f = INF;}
	sort(city+1, city+n+1);
	prevv.assign(n+1, vector<ld> (k+1, INF));
	prevv[0][0] = 0;
	for (ll i=1; i<=n; ++i)
	{
		dp.assign(n+1, vector<ld> (k+1, INF));
		for (ll j=0; j<=i; ++j)
		{
			for (ll x = 0; x<=min(i, k); ++x)
			{
				dp[j][x] = prevv[j][x];
				if (j && x) dp[j][x] = min(dp[j][x], prevv[j-1][x-1] + ld(ld(city[i].f)/(ld(j))));
				if (x) dp[j][x] = min(dp[j][x], prevv[j][x-1] + ld(ld(city[i].s)/ld(j+1)));
			}
		}
		swap(dp, prevv);
	}
	ld ans = INF;
	for (ll i=0; i<=n; ++i) ans = min(ans, prevv[i][k]);
	cout << setprecision(15) << fixed << ans << endl;
	
	return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:13:27: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 | #define input2(x, y) scanf("%lld%lld", &x, &y);
      |                      ~~~~~^~~~~~~~~~~~~~~~~~~~
Main.cpp:44:2: note: in expansion of macro 'input2'
   44 |  input2(n, k);
      |  ^~~~~~
Main.cpp:13:27: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 | #define input2(x, y) scanf("%lld%lld", &x, &y);
      |                      ~~~~~^~~~~~~~~~~~~~~~~~~~
Main.cpp:45:28: note: in expansion of macro 'input2'
   45 |  for (ll i=1; i<=n; ++i)  {input2(city[i].s, city[i].f); if (city[i].f==-1) city[i].f = INF;}
      |                            ^~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 94 ms 1268 KB Output is correct
6 Correct 173 ms 2396 KB Output is correct
7 Correct 368 ms 4404 KB Output is correct
8 Correct 411 ms 6364 KB Output is correct
9 Correct 494 ms 8280 KB Output is correct
10 Correct 467 ms 5976 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 94 ms 1268 KB Output is correct
6 Correct 173 ms 2396 KB Output is correct
7 Correct 368 ms 4404 KB Output is correct
8 Correct 411 ms 6364 KB Output is correct
9 Correct 494 ms 8280 KB Output is correct
10 Correct 467 ms 5976 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 204 ms 2832 KB Output is correct
13 Correct 241 ms 2908 KB Output is correct
14 Correct 220 ms 2832 KB Output is correct
15 Correct 434 ms 5980 KB Output is correct
16 Correct 399 ms 5980 KB Output is correct
17 Correct 452 ms 5976 KB Output is correct
18 Correct 499 ms 8280 KB Output is correct
19 Correct 455 ms 8280 KB Output is correct
20 Correct 529 ms 8284 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Incorrect 0 ms 348 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Incorrect 0 ms 348 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Incorrect 0 ms 348 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 505 ms 8328 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 94 ms 1268 KB Output is correct
6 Correct 173 ms 2396 KB Output is correct
7 Correct 368 ms 4404 KB Output is correct
8 Correct 411 ms 6364 KB Output is correct
9 Correct 494 ms 8280 KB Output is correct
10 Correct 467 ms 5976 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 204 ms 2832 KB Output is correct
13 Correct 241 ms 2908 KB Output is correct
14 Correct 220 ms 2832 KB Output is correct
15 Correct 434 ms 5980 KB Output is correct
16 Correct 399 ms 5980 KB Output is correct
17 Correct 452 ms 5976 KB Output is correct
18 Correct 499 ms 8280 KB Output is correct
19 Correct 455 ms 8280 KB Output is correct
20 Correct 529 ms 8284 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Incorrect 0 ms 348 KB Output isn't correct
30 Halted 0 ms 0 KB -