Submission #937407

# Submission time Handle Problem Language Result Execution time Memory
937407 2024-03-04T02:46:33 Z Marco_Escandon Let's Win the Election (JOI22_ho_t3) C++11
21 / 100
343 ms 2908 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];
double P[501];
void PSN(ll n,ll m)
{
    for(int i=0; i<n; i++)
    {
        priority_queue<double> q;
        for(int j = i+1; j <=n; j++) q.push(cad[j].second);
        while(q.size()>m-i) q.pop();
        while(!q.empty()) {P[i]+=q.top();q.pop();}
        //cout<<P[i]<<" ";
    }
}
double sol(ll l,ll n,ll m)
{
    vector<vector<double>> dp(n+1,vector<double>(l+2,1e9));
    double bs=1e9;
    dp[0][1]=0;
    for(int i=1; i<=n; i++)
    {
        for(int j=1; j<=l; j++)
        {
            if(j!=1)
                dp[i][j]=dp[i-1][j-1]+cad[i].first/(j-1);
            dp[i][j]=min(dp[i][j],dp[i-1][j]+cad[i].second/(double)l);
            if(j==l)
            {
                bs=min(bs,P[i]/l+dp[i][j]);
            }
                
        }
    }
    return bs;
}
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;
        if(cad[i].x==-1)
            cad[i].x=1e16;
    }
    sort(cad,cad+n+1);
    PSN(n,m);
    cout<<"\n\n";
    double bs=1e9;
    for (int i = 1; i <= m; i++) {
        double f1=sol(i,n,m);
        //cout<<f1<<"\n";
        bs=min(bs,f1);
    }
    cout<<bs;
}

Compilation message

Main.cpp: In function 'void PSN(ll, ll)':
Main.cpp:16:23: warning: comparison of integer expressions of different signedness: 'std::priority_queue<double>::size_type' {aka 'long unsigned int'} and 'll' {aka 'long long int'} [-Wsign-compare]
   16 |         while(q.size()>m-i) q.pop();
      |               ~~~~~~~~^~~~
# 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 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 9 ms 704 KB Output is correct
6 Correct 23 ms 1108 KB Output is correct
7 Correct 75 ms 1884 KB Output is correct
8 Correct 158 ms 2136 KB Output is correct
9 Correct 277 ms 2772 KB Output is correct
10 Correct 135 ms 2184 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 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 9 ms 704 KB Output is correct
6 Correct 23 ms 1108 KB Output is correct
7 Correct 75 ms 1884 KB Output is correct
8 Correct 158 ms 2136 KB Output is correct
9 Correct 277 ms 2772 KB Output is correct
10 Correct 135 ms 2184 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 30 ms 1304 KB Output is correct
13 Correct 32 ms 1272 KB Output is correct
14 Correct 31 ms 1272 KB Output is correct
15 Correct 142 ms 2020 KB Output is correct
16 Correct 140 ms 2056 KB Output is correct
17 Correct 143 ms 2272 KB Output is correct
18 Correct 278 ms 2848 KB Output is correct
19 Correct 343 ms 2908 KB Output is correct
20 Correct 280 ms 2728 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 297 ms 2756 KB Output is correct
2 Correct 283 ms 2744 KB Output is correct
3 Correct 293 ms 2884 KB Output is correct
4 Correct 292 ms 2724 KB Output is correct
5 Correct 311 ms 2760 KB Output is correct
6 Correct 291 ms 2732 KB Output is correct
7 Correct 282 ms 2764 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 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 9 ms 704 KB Output is correct
6 Correct 23 ms 1108 KB Output is correct
7 Correct 75 ms 1884 KB Output is correct
8 Correct 158 ms 2136 KB Output is correct
9 Correct 277 ms 2772 KB Output is correct
10 Correct 135 ms 2184 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 30 ms 1304 KB Output is correct
13 Correct 32 ms 1272 KB Output is correct
14 Correct 31 ms 1272 KB Output is correct
15 Correct 142 ms 2020 KB Output is correct
16 Correct 140 ms 2056 KB Output is correct
17 Correct 143 ms 2272 KB Output is correct
18 Correct 278 ms 2848 KB Output is correct
19 Correct 343 ms 2908 KB Output is correct
20 Correct 280 ms 2728 KB Output is correct
21 Incorrect 1 ms 348 KB Output isn't correct
22 Halted 0 ms 0 KB -