Submission #936940

# Submission time Handle Problem Language Result Execution time Memory
936940 2024-03-03T04:41:11 Z Marco_Escandon Let's Win the Election (JOI22_ho_t3) C++11
10 / 100
2052 ms 9048 KB
#include<bits/stdc++.h>
#define optimizar_io ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);cout.setf(ios::fixed);cout.precision(15);
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
#define x first
#define y second
pair<double,double> cad[501];
pair<double,double> dp[3][503][503];
int main()
{
    optimizar_io
    ll n,m;
    cin>>n>>m;
    cad[0]={-1,-1};
    for(int i=1; i<=n; i++)
        cin>>cad[i].second>>cad[i].first;
    sort(cad,cad+n+1);
    for(int i=0; i<2; i++)
        for(int j=0; j<=n; j++)
            for(int k=0; k<=m+2; k++)
                dp[i][j][k]={1e9,1e9};
    dp[0][1][1]={0,0};
    double bs=1e9;
    for(int i=1; i<=n; i++)
    {
        for(int j=1; j<=n; j++)
        {
            for(int k=1; k<=m+1; k++)
            {
                pair<double,double> temp={1e9,1e9};
                temp=min(temp,dp[0][j][k]);
                temp=min(temp,{dp[0][j][k-1].x+cad[i].y/j,dp[0][j][k-1].y});
                if(cad[i].first!=-1&&j!=1)
                    temp=min(temp,{(dp[0][j-1][k-1].x-dp[0][j-1][k-1].y)*(j-1)/j+dp[0][j-1][k-1].y+cad[i].x/(j-1),dp[0][j-1][k-1].y+cad[i].x/(j-1)});
                dp[1][j][k]=temp;
                if(k==m+1) bs=min(bs,dp[1][j][k].first);
            }
            //cout<<"\n";
        }
        swap(dp[0],dp[1]);
        //cout<<"\n\n";
    }
    cout<<bs;
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 8280 KB Output is correct
2 Correct 4 ms 8284 KB Output is correct
3 Correct 4 ms 8632 KB Output is correct
4 Correct 4 ms 8280 KB Output is correct
5 Correct 302 ms 8796 KB Output is correct
6 Correct 519 ms 8828 KB Output is correct
7 Correct 863 ms 9048 KB Output is correct
8 Correct 1176 ms 8836 KB Output is correct
9 Correct 1494 ms 8828 KB Output is correct
10 Correct 1099 ms 8832 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 8280 KB Output is correct
2 Correct 4 ms 8284 KB Output is correct
3 Correct 4 ms 8632 KB Output is correct
4 Correct 4 ms 8280 KB Output is correct
5 Correct 302 ms 8796 KB Output is correct
6 Correct 519 ms 8828 KB Output is correct
7 Correct 863 ms 9048 KB Output is correct
8 Correct 1176 ms 8836 KB Output is correct
9 Correct 1494 ms 8828 KB Output is correct
10 Correct 1099 ms 8832 KB Output is correct
11 Correct 3 ms 8284 KB Output is correct
12 Correct 737 ms 8844 KB Output is correct
13 Correct 684 ms 8832 KB Output is correct
14 Correct 608 ms 8836 KB Output is correct
15 Correct 1482 ms 8832 KB Output is correct
16 Correct 1344 ms 9040 KB Output is correct
17 Correct 1172 ms 8832 KB Output is correct
18 Correct 2052 ms 8840 KB Output is correct
19 Correct 1823 ms 8832 KB Output is correct
20 Correct 1623 ms 8832 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 8280 KB Output is correct
2 Correct 5 ms 8284 KB Output is correct
3 Correct 5 ms 8376 KB Output is correct
4 Correct 6 ms 8280 KB Output is correct
5 Correct 5 ms 8284 KB Output is correct
6 Correct 5 ms 8284 KB Output is correct
7 Correct 5 ms 8284 KB Output is correct
8 Correct 6 ms 8284 KB Output is correct
9 Correct 5 ms 8380 KB Output is correct
10 Correct 5 ms 8280 KB Output is correct
11 Correct 6 ms 8136 KB Output is correct
12 Correct 6 ms 8284 KB Output is correct
13 Correct 6 ms 8284 KB Output is correct
14 Incorrect 4 ms 8284 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 8280 KB Output is correct
2 Correct 5 ms 8284 KB Output is correct
3 Correct 5 ms 8376 KB Output is correct
4 Correct 6 ms 8280 KB Output is correct
5 Correct 5 ms 8284 KB Output is correct
6 Correct 5 ms 8284 KB Output is correct
7 Correct 5 ms 8284 KB Output is correct
8 Correct 6 ms 8284 KB Output is correct
9 Correct 5 ms 8380 KB Output is correct
10 Correct 5 ms 8280 KB Output is correct
11 Correct 6 ms 8136 KB Output is correct
12 Correct 6 ms 8284 KB Output is correct
13 Correct 6 ms 8284 KB Output is correct
14 Incorrect 4 ms 8284 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 8280 KB Output is correct
2 Correct 5 ms 8284 KB Output is correct
3 Correct 5 ms 8376 KB Output is correct
4 Correct 6 ms 8280 KB Output is correct
5 Correct 5 ms 8284 KB Output is correct
6 Correct 5 ms 8284 KB Output is correct
7 Correct 5 ms 8284 KB Output is correct
8 Correct 6 ms 8284 KB Output is correct
9 Correct 5 ms 8380 KB Output is correct
10 Correct 5 ms 8280 KB Output is correct
11 Correct 6 ms 8136 KB Output is correct
12 Correct 6 ms 8284 KB Output is correct
13 Correct 6 ms 8284 KB Output is correct
14 Incorrect 4 ms 8284 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2052 ms 8836 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 8280 KB Output is correct
2 Correct 4 ms 8284 KB Output is correct
3 Correct 4 ms 8632 KB Output is correct
4 Correct 4 ms 8280 KB Output is correct
5 Correct 302 ms 8796 KB Output is correct
6 Correct 519 ms 8828 KB Output is correct
7 Correct 863 ms 9048 KB Output is correct
8 Correct 1176 ms 8836 KB Output is correct
9 Correct 1494 ms 8828 KB Output is correct
10 Correct 1099 ms 8832 KB Output is correct
11 Correct 3 ms 8284 KB Output is correct
12 Correct 737 ms 8844 KB Output is correct
13 Correct 684 ms 8832 KB Output is correct
14 Correct 608 ms 8836 KB Output is correct
15 Correct 1482 ms 8832 KB Output is correct
16 Correct 1344 ms 9040 KB Output is correct
17 Correct 1172 ms 8832 KB Output is correct
18 Correct 2052 ms 8840 KB Output is correct
19 Correct 1823 ms 8832 KB Output is correct
20 Correct 1623 ms 8832 KB Output is correct
21 Correct 5 ms 8280 KB Output is correct
22 Correct 5 ms 8284 KB Output is correct
23 Correct 5 ms 8376 KB Output is correct
24 Correct 6 ms 8280 KB Output is correct
25 Correct 5 ms 8284 KB Output is correct
26 Correct 5 ms 8284 KB Output is correct
27 Correct 5 ms 8284 KB Output is correct
28 Correct 6 ms 8284 KB Output is correct
29 Correct 5 ms 8380 KB Output is correct
30 Correct 5 ms 8280 KB Output is correct
31 Correct 6 ms 8136 KB Output is correct
32 Correct 6 ms 8284 KB Output is correct
33 Correct 6 ms 8284 KB Output is correct
34 Incorrect 4 ms 8284 KB Output isn't correct
35 Halted 0 ms 0 KB -