Submission #1044530

#TimeUsernameProblemLanguageResultExecution timeMemory
1044530panLet's Win the Election (JOI22_ho_t3)C++17
0 / 100
590 ms1048580 KiB
#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 = 1e16; ll n, k; ld dp[505][505][505]; // 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); for (ll x=0; x<=n; ++x) for (ll i=0; i<=n; ++i) for (ll j=0; j<=n; ++j) dp[x][i][j] = INF; dp[0][0][0] = 0; for (ll i=1; i<=n; ++i) { for (ll j=0; j<=i; ++j) { for (ll x = 0; x<=min(i, k); ++x) { dp[i][j][x] = dp[i-1][j][x]; if (j && x) dp[i][j][x] = min(dp[i][j][x], dp[i-1][j-1][x-1] + ld(ld(city[i].f)/(ld(j)))); if (x) dp[i][j][x] = min(dp[i][j][x], dp[i-1][j][x-1] + ld(ld(city[i].s)/ld(j+1))); } } } ld ans = INF; for (ll i=0; i<=n; ++i) ans = min(ans, dp[n][i][k]); cout << setprecision(15) << fixed << ans << endl; return 0; }

Compilation message (stderr)

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...