Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifdef _DEBUG
- #define _GLIBCXX_DEBUG
- #endif
- #include <bits/stdc++.h>
- using namespace std;
- typedef long long ll;
- typedef vector<int> vi;
- typedef pair<int, int> pii;
- #define X first
- #define Y second
- #define inb push_back
- #define mk make_pair
- #define all(v) (v).begin(), (v).end()
- #define sqr(x) ((x) * (x))
- int solve()
- {
- int n, m;
- double s;
- cin >> n >> m >> s;
- vector<pair<int, double>> p(m);
- for (int i = 0; i < m; ++i)
- {
- int pt;
- double tt;
- cin >> tt >> pt;
- p[i] = mk(pt, tt / s);
- }
- vector<double> dp(n);
- for (int it = 0; it < 100000; ++it)
- {
- for (int c = 0; c < n; ++c)
- {
- dp[c] = 0;
- for (int i = 0; i < m; ++i)
- {
- double cur = 0;
- if (c + p[i].X > n - 1)
- {
- cur += p[i].Y;
- }
- else
- {
- cur += dp[c + p[i].X] * p[i].Y;
- }
- if (c)
- {
- cur += dp[c - 1] * (1.0 - p[i].Y);
- }
- dp[c] = max(cur, dp[c]);
- }
- }
- }
- cout << setprecision(15) << fixed << dp[n - 1];
- return 0;
- }
- int main()
- {
- #define TASK "casino"
- #ifdef _DEBUG
- freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
- #else
- freopen(TASK".in", "r", stdin), freopen(TASK".out", "w", stdout);
- #endif
- solve();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement