Submission #936917

# Submission time Handle Problem Language Result Execution time Memory
936917 2024-03-03T03:28:07 Z Marco_Escandon Let's Win the Election (JOI22_ho_t3) C++11
0 / 100
756 ms 1048576 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];
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);
    pair<double,double> dp[n+3][m+3][m+3];
    for(int i=0; i<n+2; i++)
        for(int j=0; j<=m+2; 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<=m+1; j++)
        {
            for(int k=1; k<=m+1; k++)
            {
                pair<double,double> temp={1e9,1e9};
                temp=min(temp,dp[i-1][j][k]);
                temp=min(temp,{dp[i-1][j][k-1].x+cad[i].y/j,dp[i-1][j][k-1].y});
                if(cad[i].first!=-1&&j!=1)
                    temp=min(temp,{(dp[i-1][j-1][k-1].x-dp[i-1][j-1][k-1].y)*(j-1)/j+dp[i-1][j-1][k-1].y+cad[i].x/(j-1),dp[i-1][j-1][k-1].y+cad[i].x/(j-1)});
                dp[i][j][k]=temp;
                if(k==m+1)
                {
                    //cout<<i<<j<<k<<":"<<temp.first<<" "<<temp.second<<"  ";
                    bs=min(bs,dp[i][j][k].first);
                }
            }
            //cout<<"\n";
        }
        //cout<<"\n\n";
    }
    cout<<bs;
}
# 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 34 ms 22584 KB Output is correct
6 Correct 187 ms 129584 KB Output is correct
7 Correct 756 ms 504656 KB Output is correct
8 Runtime error 643 ms 1048576 KB Execution killed with signal 9
9 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 34 ms 22584 KB Output is correct
6 Correct 187 ms 129584 KB Output is correct
7 Correct 756 ms 504656 KB Output is correct
8 Runtime error 643 ms 1048576 KB Execution killed with signal 9
9 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 0 ms 348 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Incorrect 0 ms 348 KB Output isn't correct
15 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 0 ms 348 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Incorrect 0 ms 348 KB Output isn't correct
15 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 0 ms 348 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Incorrect 0 ms 348 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 507 ms 1048576 KB Execution killed with signal 9
2 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 34 ms 22584 KB Output is correct
6 Correct 187 ms 129584 KB Output is correct
7 Correct 756 ms 504656 KB Output is correct
8 Runtime error 643 ms 1048576 KB Execution killed with signal 9
9 Halted 0 ms 0 KB -